diff --git a/sicvar.c b/sicvar.c index 125277e4..075a29af 100644 --- a/sicvar.c +++ b/sicvar.c @@ -456,7 +456,7 @@ int VarWrapper(SConnection * pCon, SicsInterp * pInterp, void *pData, return 1; case veFloat: VarGetFloat(pVar, &fVal); - snprintf(pBueffel,sizeof(pBueffel)-1, "%s = %g", argv[0], fVal); + snprintf(pBueffel,sizeof(pBueffel)-1, "%s = %#g", argv[0], fVal); SCWrite(pCon, pBueffel, eValue); DeleteTokenList(pList); return 1; diff --git a/site_ansto/instrument/config/anticollider/anticollider_common.tcl b/site_ansto/instrument/config/anticollider/anticollider_common.tcl index 209a3522..011ad101 100644 --- a/site_ansto/instrument/config/anticollider/anticollider_common.tcl +++ b/site_ansto/instrument/config/anticollider/anticollider_common.tcl @@ -93,6 +93,7 @@ proc ::anticollider::genveto {veto_rules} { lappend condlist $mot $range } lappend veto_region($vp(for)) [list $vp(forbid) @and $condlist] + unset condlist } elseif [info exists vp(when)] { lappend veto_region($vp(for)) [list $vp(forbid) $vp(when) $vp(in)] } else { @@ -132,12 +133,12 @@ proc ::anticollider::veto_region_acscript {args} { foreach row $veto_region($regmot) { if { [lindex $row 1] == "@and"} { set forbid [lindex $row 0] - set veto 0 + set veto 1 foreach {mot range} [lindex $row 2] { set pos [SplitReply [$mot]] foreach {lower upper} [join $range] { - if {$pos >= $lower && $pos <= $upper} { - set veto 1 + if {$pos < $lower || $pos > $upper} { + set veto 0 break } } @@ -147,7 +148,10 @@ proc ::anticollider::veto_region_acscript {args} { } else { foreach {min max} $forbid {} if {$min <= $target && $target <= $max} { - error "ERROR:The range ($forbid) is forbidden for $regmot when [lindex $row 2]" + foreach {mot range} [lindex $row 2] { + lappend msg [list $mot in $range] + } + error "ERROR:The range ($forbid) is forbidden for $regmot when [join $msg { and }]" } } } else { @@ -212,15 +216,13 @@ proc ::anticollider::init {} { lappend ::anticollider::scripts ::anticollider::veto_region_acscript proc ::anticollider::acscript {args} { set catch_status [ catch { - if {[::anticollider::enable $args] == "false"} { - return - } else { - foreach {regmot target} $args { - anticollision add 0 $regmot $target - } + foreach {regmot target} $args { + anticollision add 0 $regmot $target } - foreach script $::anticollider::scripts { - $script {*}$args + if {[::anticollider::enable $args] == "true"} { + foreach script $::anticollider::scripts { + $script {*}$args + } } } message ] handle_acscript_exception $catch_status $message diff --git a/site_ansto/instrument/config/beamline/he3_polanal.sct b/site_ansto/instrument/config/beamline/he3_polanal.sct index 1d38fc98..68ba2a24 100644 --- a/site_ansto/instrument/config/beamline/he3_polanal.sct +++ b/site_ansto/instrument/config/beamline/he3_polanal.sct @@ -4,42 +4,73 @@ driver he3_polanal = { protocol = std; class = instrument; simulation_group = rfgen_simulation; + make_args = '{has_pol true} {has_anal true}'; + group polariser = { + conditional = '[string equal -nocase ${has_pol} "true"]'; + type = float; var spin = { - type = text; readable = 900; read_command = 'polariser'; read_function = rdValue; writeable = 1; write_command = 'polariser'; check_function = chkWrite; - allowed = "+,-,0" + allowed = "+,-,Refresh" } - var Amplitude = { type = text; } - var Freq = { type = text; units = 'Hertz'; } - var Phase = { type = text; units = 'Degree'; } - var Time2 = { type = text; units = 'Second'; } - var Field = { type = text; units = 'Oersted'; } + var amplitude = { } + var freq = { units = 'Hertz'; } + var phase = { units = 'Degree'; } + var time2 = { units = 'Second'; } + var field = { units = 'Oersted'; } + var timestamp = { } } + group polariser_start = { + conditional = '[string equal -nocase ${has_pol} "true"]'; + type = float; + var spin = { } + var amplitude = { } + var freq = { units = 'Hertz'; } + var phase = { units = 'Degree'; } + var time2 = { units = 'Second'; } + var field = { units = 'Oersted'; } + var timestamp = { } + } + group analyser = { + conditional = '[string equal -nocase ${has_anal} "true"]'; + type = float; var spin = { - type = text; readable = 900; read_command = 'analyser'; read_function = rdValue; writeable = 1; write_command = 'analyser'; check_function = chkWrite; - allowed = "+,-,0" + allowed = "+,-,Refresh" } - var Amplitude = { type = text; } - var Freq = { type = text; units = 'Hertz'; } - var Phase = { type = text; units = 'Degree'; } - var Time2 = { type = text; units = 'Second'; } - var Field = { type = text; units = 'Oersted'; } + var amplitude = { } + var freq = { units = 'Hertz'; } + var phase = { units = 'Degree'; } + var time2 = { units = 'Second'; } + var field = { units = 'Oersted'; } + var timestamp = { } } + group analyser_start = { + conditional = '[string equal -nocase ${has_anal} "true"]'; + type = float; + var spin = { } + var amplitude = { } + var freq = { units = 'Hertz'; } + var phase = { units = 'Degree'; } + var time2 = { units = 'Second'; } + var field = { units = 'Oersted'; } + var timestamp = { } + } + code chkWrite = {%% [namespace current]::rdValue ${tc_root} + clientput [sct result] %%} code rdValue = {%% @@ -61,25 +92,13 @@ driver he3_polanal = { set data [lindex ${dlist} 1] } set path [pathname [sct]] - if {[llength ${dlist}] > 2} { - set new_value [lindex ${dlist} 2] - if { "${new_value}" == "NaN" } { - set new_value 0 - } - hupdateif ${path}/Amplitude "${new_value}" - } - if {[llength ${dlist}] > 3} { - hupdateif ${path}/Freq "[lindex ${dlist} 3]" - } - if {[llength ${dlist}] > 4} { - hupdateif ${path}/Phase "[lindex ${dlist} 4]" - } - if {[llength ${dlist}] > 5} { - hupdateif ${path}/Time2 "[lindex ${dlist} 5]" - } - if {[llength ${dlist}] > 6} { - hupdateif ${path}/Field "[lindex ${dlist} 6]" - } + set timestamp [clock seconds] + [namespace current]::do_update ${path}/amplitude ${dlist} 2 + [namespace current]::do_update ${path}/freq ${dlist} 3 + [namespace current]::do_update ${path}/phase ${dlist} 4 + [namespace current]::do_update ${path}/time2 ${dlist} 5 + [namespace current]::do_update ${path}/field ${dlist} 6 + hupdateif ${path}/timestamp ${timestamp} %%} code setValue = {%% @@ -87,6 +106,9 @@ driver he3_polanal = { if {[string equal -nocase [sct target] "refresh"]} { set cmd "${cmd_str}" } + if {[string equal -nocase [sct target] "minus"]} { + set cmd "${cmd_str} -" + } if {[string equal -nocase [sct target] "dn"]} { set cmd "${cmd_str} -" } @@ -96,6 +118,9 @@ driver he3_polanal = { if {[sct target] == "-" || [sct target] == -1} { set cmd "${cmd_str} -" } + if {[string equal -nocase [sct target] "plus"]} { + set cmd "${cmd_str} +" + } if {[string equal -nocase [sct target] "up"]} { set cmd "${cmd_str} +" } @@ -103,4 +128,26 @@ driver he3_polanal = { set cmd "${cmd_str} +" } %%} + code preamble = { + @TCL + proc do_update { node dlist idx } { + if {[llength ${dlist}] > ${idx}} { + if {![string is double [lindex ${dlist} ${idx}]]} { + hupdateif ${node} 0.0 + } else { + hupdateif ${node} [lindex ${dlist} ${idx}] + } + } + } + @END + } + code postamble = { + @TCL + proc stash {node} { + foreach arg {spin amplitude freq phase time2 field timestamp} { + hupdateif ${node}_start/${arg} [hval ${node}/${arg}] + } + } + @END + } } diff --git a/site_ansto/instrument/config/environment/magneticField/sct_bruker.tcl b/site_ansto/instrument/config/environment/magneticField/sct_bruker.tcl index a195b1dc..7093b2d7 100644 --- a/site_ansto/instrument/config/environment/magneticField/sct_bruker.tcl +++ b/site_ansto/instrument/config/environment/magneticField/sct_bruker.tcl @@ -10,9 +10,12 @@ proc ::scobj::bruker::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 fd [open "../log/bruker_[basename ${tc_root}].log" "a"] - set line "[clock format [clock seconds] -format "%T"] ${debug_string}" - puts ${fd} "${line}" + set now [clock seconds] + set ts [clock format ${now} -format "%Y%m%d"] + set log_file_name "../log/bruker_[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 ] @@ -51,7 +54,9 @@ proc ::scobj::bruker::add_driver {name device_class simulation_flag ip_address t makesctcontroller sct_${name} astvelsel ${ip_address}:${tcp_port} } } else { - ::scobj::bruker::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for bruker" + ::scobj::bruker::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for bruker" + ::scobj::bruker::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL } ::scobj::bruker::sics_log 1 "::scobj::bruker::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" ::scobj::bruker::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol} @@ -69,7 +74,7 @@ namespace eval ::scobj::bruker { proc add_bruker {name ip_address tcp_port id datype {tol 0.1}} { set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - ::scobj::bruker::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${{tol}" "${0.1}}" + ::scobj::bruker::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol} } clientput "file evaluation of sct_bruker.tcl" @@ -108,20 +113,31 @@ proc ::scobj::bruker::read_config {} { 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} astvelsel ${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 "terminator"] } { + 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"]" } } @@ -132,6 +148,7 @@ proc ::scobj::bruker::read_config {} { if { [dict exists $v "timeout"] } { ${asyncqueue} timeout "[dict get $v "timeout"]" } + makesctcontroller sct_${name} aqadapter ${asyncqueue} } set arg_list [list] set missing_list [list] @@ -148,11 +165,7 @@ proc ::scobj::bruker::read_config {} { if { [llength $missing_list] > 0 } { error "$name is missing configuration values $missing_list" } - if { [string equal -nocase ${asyncqueue} "sct"] } { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list - } else { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list - } + ${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/sct_knauer_pump.tcl b/site_ansto/instrument/config/environment/sct_knauer_pump.tcl index 1f269659..47d7d8a5 100644 --- a/site_ansto/instrument/config/environment/sct_knauer_pump.tcl +++ b/site_ansto/instrument/config/environment/sct_knauer_pump.tcl @@ -10,9 +10,12 @@ proc ::scobj::knauer_pump::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 fd [open "../log/knauer_pump_[basename ${tc_root}].log" "a"] - set line "[clock format [clock seconds] -format "%T"] ${debug_string}" - puts ${fd} "${line}" + set now [clock seconds] + set ts [clock format ${now} -format "%Y%m%d"] + set log_file_name "../log/knauer_pump_[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 ] @@ -583,7 +586,12 @@ proc ::scobj::knauer_pump::volume_checkstatus {tc_root} { # volume_checkstatus hook code goes here if {[sct driving]} { set sp "[sct target]" - set pv "[hval ${tc_root}/[sct driveable]]" + 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] } { @@ -881,9 +889,6 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio set scobj_hpath /sics/${name} hfactory ${scobj_hpath}/dummy plain spy none - hsetprop ${scobj_hpath}/dummy data "false" - hsetprop ${scobj_hpath}/dummy klass "@none" - hsetprop ${scobj_hpath}/dummy type "part" hfactory ${scobj_hpath}/dummy/glp plain user text hsetprop ${scobj_hpath}/dummy/glp read ${ns}::getValue ${scobj_hpath} read_glp {GLP?} @@ -898,6 +903,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/dummy/glp type "part" hsetprop ${scobj_hpath}/dummy/glp nxalias "${name}_dummy_glp" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/dummy/glp 1 + hsetprop ${scobj_hpath}/dummy/glp simulated false + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/dummy/glp simulated true + } + hfactory ${scobj_hpath}/dummy/status plain user text hsetprop ${scobj_hpath}/dummy/status read ${ns}::getValue ${scobj_hpath} read_status {STATUS?} hsetprop ${scobj_hpath}/dummy/status read_status ${ns}::read_status ${scobj_hpath} @@ -912,16 +925,17 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/dummy/status nxalias "${name}_dummy_status" if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/dummy/glp 1 ${sct_controller} poll ${scobj_hpath}/dummy/status 1 + hsetprop ${scobj_hpath}/dummy/status simulated false } else { ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/dummy/status simulated true } + hsetprop ${scobj_hpath}/dummy data "false" + hsetprop ${scobj_hpath}/dummy klass "@none" + hsetprop ${scobj_hpath}/dummy type "part" hfactory ${scobj_hpath}/pump plain spy none - hsetprop ${scobj_hpath}/pump data "true" - hsetprop ${scobj_hpath}/pump klass "@none" - hsetprop ${scobj_hpath}/pump type "part" hfactory ${scobj_hpath}/pump/remote plain user int hsetprop ${scobj_hpath}/pump/remote read ${ns}::getValue ${scobj_hpath} remote_read {REMOTE?} @@ -940,6 +954,15 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/pump/remote type "part" hsetprop ${scobj_hpath}/pump/remote nxalias "${name}_pump_remote" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/pump/remote 1 + ${sct_controller} write ${scobj_hpath}/pump/remote + hsetprop ${scobj_hpath}/pump/remote simulated false + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/pump/remote simulated true + } + hfactory ${scobj_hpath}/pump/state plain user text hsetprop ${scobj_hpath}/pump/state read ${ns}::state_fetch ${scobj_hpath} rdValue { } hsetprop ${scobj_hpath}/pump/state rdValue ${ns}::rdValue ${scobj_hpath} @@ -953,6 +976,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/pump/state type "part" hsetprop ${scobj_hpath}/pump/state nxalias "${name}_pump_state" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/pump/state 1 + hsetprop ${scobj_hpath}/pump/state simulated false + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/pump/state simulated true + } + hfactory ${scobj_hpath}/pump/status plain user text hsetprop ${scobj_hpath}/pump/status read ${ns}::status_fetch ${scobj_hpath} rdValue { } hsetprop ${scobj_hpath}/pump/status rdValue ${ns}::rdValue ${scobj_hpath} @@ -967,18 +998,17 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/pump/status nxalias "${name}_pump_status" if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/pump/remote 1 - ${sct_controller} poll ${scobj_hpath}/pump/state 1 ${sct_controller} poll ${scobj_hpath}/pump/status 1 - ${sct_controller} write ${scobj_hpath}/pump/remote + hsetprop ${scobj_hpath}/pump/status simulated false } else { ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/pump/status simulated true } + hsetprop ${scobj_hpath}/pump data "true" + hsetprop ${scobj_hpath}/pump klass "@none" + hsetprop ${scobj_hpath}/pump type "part" hfactory ${scobj_hpath}/pump/flow plain spy none - hsetprop ${scobj_hpath}/pump/flow data "true" - hsetprop ${scobj_hpath}/pump/flow klass "@none" - hsetprop ${scobj_hpath}/pump/flow type "part" hfactory ${scobj_hpath}/pump/flow/pval plain user float hsetprop ${scobj_hpath}/pump/flow/pval read ${ns}::flow_fetch ${scobj_hpath} rdValue { } @@ -994,6 +1024,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/pump/flow/pval units "mL/min" hsetprop ${scobj_hpath}/pump/flow/pval nxalias "${name}_pump_flow_pval" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/pump/flow/pval 1 + hsetprop ${scobj_hpath}/pump/flow/pval simulated false + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/pump/flow/pval simulated true + } + hfactory ${scobj_hpath}/pump/flow/setp plain user float hsetprop ${scobj_hpath}/pump/flow/setp write ${ns}::flow_write ${scobj_hpath} noResponse { } hsetprop ${scobj_hpath}/pump/flow/setp noResponse ${ns}::noResponse ${scobj_hpath} @@ -1013,16 +1051,17 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/pump/flow/setp nxalias "${name}_pump_flow_setp" if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/pump/flow/pval 1 ${sct_controller} write ${scobj_hpath}/pump/flow/setp + hsetprop ${scobj_hpath}/pump/flow/setp simulated false } else { ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/pump/flow/setp simulated true } + hsetprop ${scobj_hpath}/pump/flow data "true" + hsetprop ${scobj_hpath}/pump/flow klass "@none" + hsetprop ${scobj_hpath}/pump/flow type "part" hfactory ${scobj_hpath}/pump/ratio plain spy none - hsetprop ${scobj_hpath}/pump/ratio data "true" - hsetprop ${scobj_hpath}/pump/ratio klass "@none" - hsetprop ${scobj_hpath}/pump/ratio type "part" hfactory ${scobj_hpath}/pump/ratio/pval plain user text hsetprop ${scobj_hpath}/pump/ratio/pval read ${ns}::ratio_fetch ${scobj_hpath} rdValue { } @@ -1038,6 +1077,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/pump/ratio/pval units "percent" hsetprop ${scobj_hpath}/pump/ratio/pval nxalias "${name}_pump_ratio_pval" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/pump/ratio/pval 1 + hsetprop ${scobj_hpath}/pump/ratio/pval simulated false + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/pump/ratio/pval simulated true + } + hfactory ${scobj_hpath}/pump/ratio/setp plain user text hsetprop ${scobj_hpath}/pump/ratio/setp write ${ns}::ratio_write ${scobj_hpath} noResponse { } hsetprop ${scobj_hpath}/pump/ratio/setp noResponse ${ns}::noResponse ${scobj_hpath} @@ -1055,16 +1102,17 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/pump/ratio/setp nxalias "${name}_pump_ratio_setp" if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/pump/ratio/pval 1 ${sct_controller} write ${scobj_hpath}/pump/ratio/setp + hsetprop ${scobj_hpath}/pump/ratio/setp simulated false } else { ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/pump/ratio/setp simulated true } + hsetprop ${scobj_hpath}/pump/ratio data "true" + hsetprop ${scobj_hpath}/pump/ratio klass "@none" + hsetprop ${scobj_hpath}/pump/ratio type "part" hfactory ${scobj_hpath}/pump/volume plain spy none - hsetprop ${scobj_hpath}/pump/volume data "true" - hsetprop ${scobj_hpath}/pump/volume klass "@none" - hsetprop ${scobj_hpath}/pump/volume type "part" hfactory ${scobj_hpath}/pump/volume/pval plain user float hsetprop ${scobj_hpath}/pump/volume/pval read ${ns}::volume_fetch ${scobj_hpath} volume_read { } @@ -1080,6 +1128,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/pump/volume/pval units "mL" hsetprop ${scobj_hpath}/pump/volume/pval nxalias "${name}_pump_volume_pval" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/pump/volume/pval 1 + hsetprop ${scobj_hpath}/pump/volume/pval simulated false + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/pump/volume/pval simulated true + } + hfactory ${scobj_hpath}/pump/volume/setp plain user float hsetprop ${scobj_hpath}/pump/volume/setp read ${ns}::volume_fsm ${scobj_hpath} volume_store { } hsetprop ${scobj_hpath}/pump/volume/setp volume_store ${ns}::volume_store ${scobj_hpath} @@ -1107,18 +1163,20 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hsetprop ${scobj_hpath}/pump/volume/setp nxalias "${name}_pump_volume_setp" if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/pump/volume/pval 1 ${sct_controller} poll ${scobj_hpath}/pump/volume/setp 1 ${sct_controller} write ${scobj_hpath}/pump/volume/setp + hsetprop ${scobj_hpath}/pump/volume/setp simulated false } else { ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + hsetprop ${scobj_hpath}/pump/volume/setp simulated true } + hsetprop ${scobj_hpath}/pump/volume data "true" + hsetprop ${scobj_hpath}/pump/volume klass "@none" + hsetprop ${scobj_hpath}/pump/volume type "part" + ansto_makesctdrive ${name}_pump_volume_setp ${scobj_hpath}/pump/volume/setp ${scobj_hpath}/pump/volume/pval ${sct_controller} hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 0 - if {[string equal -nocase "${simulation_flag}" "false"]} { - ansto_makesctdrive ${name}_pump_volume_setp ${scobj_hpath}/pump/volume/setp ${scobj_hpath}/pump/volume/pval ${sct_controller} - } # mkDriver hook code starts #hset ${scobj_hpath}/pump/remote 1 # mkDriver hook code ends @@ -1138,7 +1196,9 @@ proc ::scobj::knauer_pump::add_driver {name device_class simulation_flag ip_addr makesctcontroller sct_${name} knauer_ap ${ip_address}:${tcp_port} } } else { - ::scobj::knauer_pump::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for knauer_pump" + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for knauer_pump" + ::scobj::knauer_pump::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL } ::scobj::knauer_pump::sics_log 1 "::scobj::knauer_pump::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" ::scobj::knauer_pump::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} @@ -1156,7 +1216,7 @@ namespace eval ::scobj::knauer_pump { proc add_knauer_pump {name ip_address tcp_port} { set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - ::scobj::knauer_pump::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} + ::scobj::knauer_pump::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} } clientput "file evaluation of sct_knauer_pump.tcl" @@ -1195,20 +1255,31 @@ proc ::scobj::knauer_pump::read_config {} { 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} knauer_ap ${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 "terminator"] } { + 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"]" } } @@ -1219,12 +1290,9 @@ proc ::scobj::knauer_pump::read_config {} { if { [dict exists $v "timeout"] } { ${asyncqueue} timeout "[dict get $v "timeout"]" } + makesctcontroller sct_${name} aqadapter ${asyncqueue} } - if { [string equal -nocase ${asyncqueue} "sct"] } { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} - } else { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} - } + ${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } } } diff --git a/site_ansto/instrument/config/environment/sct_mvp_valve.tcl b/site_ansto/instrument/config/environment/sct_mvp_valve.tcl index 0bd5761d..7fd5c536 100644 --- a/site_ansto/instrument/config/environment/sct_mvp_valve.tcl +++ b/site_ansto/instrument/config/environment/sct_mvp_valve.tcl @@ -10,9 +10,12 @@ proc ::scobj::mvp_valve::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 fd [open "../log/mvp_valve_[basename ${tc_root}].log" "a"] - set line "[clock format [clock seconds] -format "%T"] ${debug_string}" - puts ${fd} "${line}" + set now [clock seconds] + set ts [clock format ${now} -format "%Y%m%d"] + set log_file_name "../log/mvp_valve_[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 ] @@ -59,7 +62,7 @@ namespace eval ::scobj::mvp_valve { proc add_mvp_valve {name ip_address tcp_port id datype} { set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - ::scobj::mvp_valve::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" + ::scobj::mvp_valve::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} } clientput "file evaluation of sct_mvp_valve.tcl" @@ -95,34 +98,7 @@ proc ::scobj::mvp_valve::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mvp_valve"] } { - if { ![string equal -nocase "${simulation_flag}" "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" - } 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] - } - } 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 - 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"]" - } - } + ::scobj::mvp_valve::sics_log 9 "No sctcontroller for mvp_valve" set arg_list [list] set missing_list [list] foreach arg {id datype} { @@ -138,11 +114,7 @@ proc ::scobj::mvp_valve::read_config {} { if { [llength $missing_list] > 0 } { error "$name is missing configuration values $missing_list" } - if { [string equal -nocase ${asyncqueue} "sct"] } { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list - } else { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list - } + ${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/sct_syringe_pump.tcl b/site_ansto/instrument/config/environment/sct_syringe_pump.tcl index dd4a923d..3388b868 100644 --- a/site_ansto/instrument/config/environment/sct_syringe_pump.tcl +++ b/site_ansto/instrument/config/environment/sct_syringe_pump.tcl @@ -10,9 +10,12 @@ proc ::scobj::syringe_pump::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 fd [open "../log/syringe_pump_[basename ${tc_root}].log" "a"] - set line "[clock format [clock seconds] -format "%T"] ${debug_string}" - puts ${fd} "${line}" + set now [clock seconds] + set ts [clock format ${now} -format "%Y%m%d"] + set log_file_name "../log/syringe_pump_[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 ] @@ -51,7 +54,9 @@ proc ::scobj::syringe_pump::add_driver {name device_class simulation_flag ip_add makesctcontroller sct_${name} syringe ${ip_address}:${tcp_port} } } else { - ::scobj::syringe_pump::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for syringe_pump" + ::scobj::syringe_pump::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for syringe_pump" + ::scobj::syringe_pump::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL } ::scobj::syringe_pump::sics_log 1 "::scobj::syringe_pump::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}" ::scobj::syringe_pump::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} @@ -69,7 +74,7 @@ namespace eval ::scobj::syringe_pump { proc add_syringe_pump {name ip_address tcp_port id datype} { set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - ::scobj::syringe_pump::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" + ::scobj::syringe_pump::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} } clientput "file evaluation of sct_syringe_pump.tcl" @@ -108,20 +113,31 @@ proc ::scobj::syringe_pump::read_config {} { 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} syringe ${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 "terminator"] } { + 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"]" } } @@ -132,6 +148,7 @@ proc ::scobj::syringe_pump::read_config {} { if { [dict exists $v "timeout"] } { ${asyncqueue} timeout "[dict get $v "timeout"]" } + makesctcontroller sct_${name} aqadapter ${asyncqueue} } set arg_list [list] set missing_list [list] @@ -148,11 +165,7 @@ proc ::scobj::syringe_pump::read_config {} { if { [llength $missing_list] > 0 } { error "$name is missing configuration values $missing_list" } - if { [string equal -nocase ${asyncqueue} "sct"] } { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list - } else { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list - } + ${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/eurotherm_3200.sct b/site_ansto/instrument/config/environment/temperature/eurotherm_3200.sct index 5f99100e..c06a97b7 100644 --- a/site_ansto/instrument/config/environment/temperature/eurotherm_3200.sct +++ b/site_ansto/instrument/config/environment/temperature/eurotherm_3200.sct @@ -3,8 +3,8 @@ driver eurotherm_3200 = { protocol = modbus_ap; class = environment; simulation_group = environment_simulation; - add_args = 'id datype dev_id tol'; - make_args = 'id datype dev_id tol'; + add_args = 'id datype dev_id {tol 5 } {lowerlimit 0} {upperlimit 500}'; + make_args = 'id datype dev_id {tol 5} {lowerlimit 0} {upperlimit 500}'; group util = { data = false; control = false; nxsave = false; mutable = false; @@ -17,7 +17,7 @@ driver eurotherm_3200 = { var sensor = { read_command = '1'; permlink = 'T.S01'; }; writeable = 1; var setpoint = { read_command = '2'; write_command = '2'; permlink = 'T.SP01'; - driveable = loop1/sensor; lowerlimit = 0; upperlimit =40; tolerance = '${tol}'; + driveable = loop1/sensor; lowerlimit = '${lowerlimit}'; upperlimit = '${upperlimit}'; tolerance = '${tol}'; }; } group loop1_extra = { diff --git a/site_ansto/instrument/config/environment/temperature/sct_eurotherm_3200.tcl b/site_ansto/instrument/config/environment/temperature/sct_eurotherm_3200.tcl index bf629afc..b4e7aea2 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_eurotherm_3200.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_eurotherm_3200.tcl @@ -10,9 +10,12 @@ proc ::scobj::eurotherm_3200::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 fd [open "../log/eurotherm_3200_[basename ${tc_root}].log" "a"] - set line "[clock format [clock seconds] -format "%T"] ${debug_string}" - puts ${fd} "${line}" + set now [clock seconds] + set ts [clock format ${now} -format "%Y%m%d"] + set log_file_name "../log/eurotherm_3200_[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 ] @@ -86,7 +89,12 @@ proc ::scobj::eurotherm_3200::checkstatus {tc_root} { # checkstatus hook code goes here if {[sct driving]} { set sp "[sct target]" - set pv "[hval ${tc_root}/[sct driveable]]" + 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] } { @@ -224,8 +232,8 @@ proc ::scobj::eurotherm_3200::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id tol } { - ::scobj::eurotherm_3200::sics_log 9 "::scobj::eurotherm_3200::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" +proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id {tol 5} {lowerlimit 0} {upperlimit 500} } { + ::scobj::eurotherm_3200::sics_log 9 "::scobj::eurotherm_3200::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} ${lowerlimit} ${upperlimit}" set ns "[namespace current]" set catch_status [ catch { @@ -237,9 +245,6 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula set scobj_hpath /sics/${name} hfactory ${scobj_hpath}/loop1 plain spy none - hsetprop ${scobj_hpath}/loop1 data "true" - hsetprop ${scobj_hpath}/loop1 klass "@none" - hsetprop ${scobj_hpath}/loop1 type "part" hfactory ${scobj_hpath}/loop1/sensor plain user float hsetprop ${scobj_hpath}/loop1/sensor read ${ns}::getValue ${scobj_hpath} rdValue {1} @@ -256,6 +261,14 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1/sensor type "part" hsetprop ${scobj_hpath}/loop1/sensor nxalias "${name}_loop1_sensor" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/loop1/sensor 1 + hsetprop ${scobj_hpath}/loop1/sensor simulated false + } else { + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1/sensor simulated true + } + hfactory ${scobj_hpath}/loop1/setpoint plain user float hsetprop ${scobj_hpath}/loop1/setpoint read ${ns}::getValue ${scobj_hpath} rdValue {2} hsetprop ${scobj_hpath}/loop1/setpoint rdValue ${ns}::rdValue ${scobj_hpath} @@ -271,8 +284,8 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1/setpoint data true hsetprop ${scobj_hpath}/loop1/setpoint mutable true hsetprop ${scobj_hpath}/loop1/setpoint nxsave true - hsetprop ${scobj_hpath}/loop1/setpoint lowerlimit 0 - hsetprop ${scobj_hpath}/loop1/setpoint upperlimit 40 + hsetprop ${scobj_hpath}/loop1/setpoint lowerlimit ${lowerlimit} + hsetprop ${scobj_hpath}/loop1/setpoint upperlimit ${upperlimit} hsetprop ${scobj_hpath}/loop1/setpoint tolerance ${tol} hsetprop ${scobj_hpath}/loop1/setpoint permlink data_set "T[format "%02d" ${id}]SP01" hsetprop ${scobj_hpath}/loop1/setpoint @description "T[format "%02d" ${id}]SP01" @@ -283,17 +296,19 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1/setpoint nxalias "${name}_loop1_setpoint" if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/loop1/sensor 1 ${sct_controller} poll ${scobj_hpath}/loop1/setpoint 1 ${sct_controller} write ${scobj_hpath}/loop1/setpoint + hsetprop ${scobj_hpath}/loop1/setpoint simulated false } else { ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1/setpoint simulated true } + hsetprop ${scobj_hpath}/loop1 data "true" + hsetprop ${scobj_hpath}/loop1 klass "@none" + hsetprop ${scobj_hpath}/loop1 type "part" + ansto_makesctdrive ${name}_loop1_setpoint ${scobj_hpath}/loop1/setpoint ${scobj_hpath}/loop1/sensor ${sct_controller} hfactory ${scobj_hpath}/loop1_extra plain spy none - hsetprop ${scobj_hpath}/loop1_extra data "false" - hsetprop ${scobj_hpath}/loop1_extra klass "@none" - hsetprop ${scobj_hpath}/loop1_extra type "part" hfactory ${scobj_hpath}/loop1_extra/active_setpoint plain user float hsetprop ${scobj_hpath}/loop1_extra/active_setpoint read ${ns}::getValue ${scobj_hpath} rdValue {15} @@ -307,6 +322,14 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1_extra/active_setpoint type "part" hsetprop ${scobj_hpath}/loop1_extra/active_setpoint nxalias "${name}_loop1_extra_active_setpoint" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/loop1_extra/active_setpoint 1 + hsetprop ${scobj_hpath}/loop1_extra/active_setpoint simulated false + } else { + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1_extra/active_setpoint simulated true + } + hfactory ${scobj_hpath}/loop1_extra/alarm1_thresh plain user float hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh read ${ns}::getValue ${scobj_hpath} rdValue {13} hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh rdValue ${ns}::rdValue ${scobj_hpath} @@ -322,6 +345,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh type "part" hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh nxalias "${name}_loop1_extra_alarm1_thresh" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/loop1_extra/alarm1_thresh 1 + ${sct_controller} write ${scobj_hpath}/loop1_extra/alarm1_thresh + hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh simulated false + } else { + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh simulated true + } + hfactory ${scobj_hpath}/loop1_extra/alarm2_thresh plain user float hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh read ${ns}::getValue ${scobj_hpath} rdValue {14} hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh rdValue ${ns}::rdValue ${scobj_hpath} @@ -337,6 +369,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh type "part" hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh nxalias "${name}_loop1_extra_alarm2_thresh" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/loop1_extra/alarm2_thresh 1 + ${sct_controller} write ${scobj_hpath}/loop1_extra/alarm2_thresh + hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh simulated false + } else { + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh simulated true + } + hfactory ${scobj_hpath}/loop1_extra/manual_output plain user float hsetprop ${scobj_hpath}/loop1_extra/manual_output read ${ns}::getValue ${scobj_hpath} rdValue {3} hsetprop ${scobj_hpath}/loop1_extra/manual_output rdValue ${ns}::rdValue ${scobj_hpath} @@ -349,6 +390,14 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1_extra/manual_output type "part" hsetprop ${scobj_hpath}/loop1_extra/manual_output nxalias "${name}_loop1_extra_manual_output" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/loop1_extra/manual_output 1 + hsetprop ${scobj_hpath}/loop1_extra/manual_output simulated false + } else { + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1_extra/manual_output simulated true + } + hfactory ${scobj_hpath}/loop1_extra/power_limit_high plain user float hsetprop ${scobj_hpath}/loop1_extra/power_limit_high read ${ns}::getValue ${scobj_hpath} rdValue {30} hsetprop ${scobj_hpath}/loop1_extra/power_limit_high rdValue ${ns}::rdValue ${scobj_hpath} @@ -364,6 +413,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1_extra/power_limit_high type "part" hsetprop ${scobj_hpath}/loop1_extra/power_limit_high nxalias "${name}_loop1_extra_power_limit_high" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/loop1_extra/power_limit_high 1 + ${sct_controller} write ${scobj_hpath}/loop1_extra/power_limit_high + hsetprop ${scobj_hpath}/loop1_extra/power_limit_high simulated false + } else { + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1_extra/power_limit_high simulated true + } + hfactory ${scobj_hpath}/loop1_extra/power_limit_low plain user float hsetprop ${scobj_hpath}/loop1_extra/power_limit_low read ${ns}::getValue ${scobj_hpath} rdValue {31} hsetprop ${scobj_hpath}/loop1_extra/power_limit_low rdValue ${ns}::rdValue ${scobj_hpath} @@ -379,6 +437,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1_extra/power_limit_low type "part" hsetprop ${scobj_hpath}/loop1_extra/power_limit_low nxalias "${name}_loop1_extra_power_limit_low" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/loop1_extra/power_limit_low 1 + ${sct_controller} write ${scobj_hpath}/loop1_extra/power_limit_low + hsetprop ${scobj_hpath}/loop1_extra/power_limit_low simulated false + } else { + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1_extra/power_limit_low simulated true + } + hfactory ${scobj_hpath}/loop1_extra/power_slew_rate plain user float hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate read ${ns}::getValue ${scobj_hpath} rdValue {37} hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate rdValue ${ns}::rdValue ${scobj_hpath} @@ -394,6 +461,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate type "part" hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate nxalias "${name}_loop1_extra_power_slew_rate" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/loop1_extra/power_slew_rate 1 + ${sct_controller} write ${scobj_hpath}/loop1_extra/power_slew_rate + hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate simulated false + } else { + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate simulated true + } + hfactory ${scobj_hpath}/loop1_extra/setpoint_slew_rate plain user float hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate read ${ns}::getValue ${scobj_hpath} rdValue {35} hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate rdValue ${ns}::rdValue ${scobj_hpath} @@ -409,6 +485,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate type "part" hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate nxalias "${name}_loop1_extra_setpoint_slew_rate" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/loop1_extra/setpoint_slew_rate 1 + ${sct_controller} write ${scobj_hpath}/loop1_extra/setpoint_slew_rate + hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate simulated false + } else { + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate simulated true + } + hfactory ${scobj_hpath}/loop1_extra/working_output plain user float hsetprop ${scobj_hpath}/loop1_extra/working_output read ${ns}::getValue ${scobj_hpath} rdValue {4} hsetprop ${scobj_hpath}/loop1_extra/working_output rdValue ${ns}::rdValue ${scobj_hpath} @@ -421,6 +506,14 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1_extra/working_output type "part" hsetprop ${scobj_hpath}/loop1_extra/working_output nxalias "${name}_loop1_extra_working_output" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/loop1_extra/working_output 1 + hsetprop ${scobj_hpath}/loop1_extra/working_output simulated false + } else { + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1_extra/working_output simulated true + } + hfactory ${scobj_hpath}/loop1_extra/working_setpoint plain user float hsetprop ${scobj_hpath}/loop1_extra/working_setpoint read ${ns}::getValue ${scobj_hpath} rdValue {5} hsetprop ${scobj_hpath}/loop1_extra/working_setpoint rdValue ${ns}::rdValue ${scobj_hpath} @@ -434,30 +527,17 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/loop1_extra/working_setpoint nxalias "${name}_loop1_extra_working_setpoint" if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/loop1_extra/active_setpoint 1 - ${sct_controller} poll ${scobj_hpath}/loop1_extra/alarm1_thresh 1 - ${sct_controller} poll ${scobj_hpath}/loop1_extra/alarm2_thresh 1 - ${sct_controller} poll ${scobj_hpath}/loop1_extra/manual_output 1 - ${sct_controller} poll ${scobj_hpath}/loop1_extra/power_limit_high 1 - ${sct_controller} poll ${scobj_hpath}/loop1_extra/power_limit_low 1 - ${sct_controller} poll ${scobj_hpath}/loop1_extra/power_slew_rate 1 - ${sct_controller} poll ${scobj_hpath}/loop1_extra/setpoint_slew_rate 1 - ${sct_controller} poll ${scobj_hpath}/loop1_extra/working_output 1 ${sct_controller} poll ${scobj_hpath}/loop1_extra/working_setpoint 1 - ${sct_controller} write ${scobj_hpath}/loop1_extra/alarm1_thresh - ${sct_controller} write ${scobj_hpath}/loop1_extra/alarm2_thresh - ${sct_controller} write ${scobj_hpath}/loop1_extra/power_limit_high - ${sct_controller} write ${scobj_hpath}/loop1_extra/power_limit_low - ${sct_controller} write ${scobj_hpath}/loop1_extra/power_slew_rate - ${sct_controller} write ${scobj_hpath}/loop1_extra/setpoint_slew_rate + hsetprop ${scobj_hpath}/loop1_extra/working_setpoint simulated false } else { ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200" + hsetprop ${scobj_hpath}/loop1_extra/working_setpoint simulated true } + hsetprop ${scobj_hpath}/loop1_extra data "false" + hsetprop ${scobj_hpath}/loop1_extra klass "@none" + hsetprop ${scobj_hpath}/loop1_extra type "part" hfactory ${scobj_hpath}/util plain spy none - hsetprop ${scobj_hpath}/util data "false" - hsetprop ${scobj_hpath}/util klass "@none" - hsetprop ${scobj_hpath}/util type "part" hfactory ${scobj_hpath}/util/mode plain user text hsetprop ${scobj_hpath}/util/mode control false @@ -481,20 +561,20 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula hsetprop ${scobj_hpath}/util/unit sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/util/unit type "part" hsetprop ${scobj_hpath}/util/unit nxalias "${name}_util_unit" + hsetprop ${scobj_hpath}/util data "false" + hsetprop ${scobj_hpath}/util klass "@none" + hsetprop ${scobj_hpath}/util type "part" hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase "${simulation_flag}" "false"]} { - ansto_makesctdrive ${name}_loop1_setpoint ${scobj_hpath}/loop1/setpoint ${scobj_hpath}/loop1/sensor ${sct_controller} - } # mkDriver hook code goes here } catch_message ] handle_exception ${catch_status} ${catch_message} } -proc ::scobj::eurotherm_3200::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id tol} { +proc ::scobj::eurotherm_3200::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id {tol 5 } {lowerlimit 0} {upperlimit 500}} { set catch_status [ catch { - ::scobj::eurotherm_3200::sics_log 9 "::scobj::eurotherm_3200::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::eurotherm_3200::sics_log 9 "::scobj::eurotherm_3200::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} ${lowerlimit} ${upperlimit}" if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::eurotherm_3200::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" @@ -504,10 +584,12 @@ proc ::scobj::eurotherm_3200::add_driver {name device_class simulation_flag ip_a makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port} } } else { - ::scobj::eurotherm_3200::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for eurotherm_3200" + ::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for eurotherm_3200" + ::scobj::eurotherm_3200::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL } - ::scobj::eurotherm_3200::sics_log 1 "::scobj::eurotherm_3200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - ::scobj::eurotherm_3200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} + ::scobj::eurotherm_3200::sics_log 1 "::scobj::eurotherm_3200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} ${lowerlimit} ${upperlimit}" + ::scobj::eurotherm_3200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} ${lowerlimit} ${upperlimit} } catch_message ] handle_exception ${catch_status} ${catch_message} } @@ -520,9 +602,9 @@ namespace eval ::scobj::eurotherm_3200 { namespace export add_driver } -proc add_eurotherm_3200 {name ip_address tcp_port id datype dev_id tol} { +proc add_eurotherm_3200 {name ip_address tcp_port id datype dev_id {tol 5 } {lowerlimit 0} {upperlimit 500}} { set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - ::scobj::eurotherm_3200::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${dev_id}" "${tol}" + ::scobj::eurotherm_3200::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} ${lowerlimit} ${upperlimit} } clientput "file evaluation of sct_eurotherm_3200.tcl" @@ -561,20 +643,31 @@ proc ::scobj::eurotherm_3200::read_config {} { 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} modbus_ap ${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 "terminator"] } { + 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"]" } } @@ -585,14 +678,19 @@ proc ::scobj::eurotherm_3200::read_config {} { 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 datype dev_id tol} { + array unset default_map + array set default_map [list tol 5 lowerlimit 0 upperlimit 500] + foreach arg {id datype dev_id tol lowerlimit upperlimit} { if {[dict exists $u $arg]} { lappend arg_list "[dict get $u $arg]" } elseif {[dict exists $v $arg]} { lappend arg_list "[dict get $v $arg]" + } elseif {[info exists default_map($arg)]} { + lappend arg_list $default_map($arg) } else { ${ns}::sics_log 9 "Missing configuration value $arg" lappend missing_list $arg @@ -601,11 +699,7 @@ proc ::scobj::eurotherm_3200::read_config {} { if { [llength $missing_list] > 0 } { error "$name is missing configuration values $missing_list" } - if { [string equal -nocase ${asyncqueue} "sct"] } { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list - } else { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list - } + ${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl b/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl index e6bb69eb..da3e1158 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl @@ -10,9 +10,12 @@ proc ::scobj::srs_sr630::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 fd [open "../log/srs_sr630_[basename ${tc_root}].log" "a"] - set line "[clock format [clock seconds] -format "%T"] ${debug_string}" - puts ${fd} "${line}" + set now [clock seconds] + set ts [clock format ${now} -format "%Y%m%d"] + set log_file_name "../log/srs_sr630_[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 ] @@ -217,6 +220,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/id type "part" hsetprop ${scobj_hpath}/id nxalias "${name}_id" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/id 600 + hsetprop ${scobj_hpath}/id simulated false + } else { + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" + hsetprop ${scobj_hpath}/id simulated true + } + hfactory ${scobj_hpath}/sensor_01 plain user float hsetprop ${scobj_hpath}/sensor_01 read ${ns}::getSensor ${scobj_hpath} readSensor {1} hsetprop ${scobj_hpath}/sensor_01 readSensor ${ns}::readSensor ${scobj_hpath} @@ -230,6 +241,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/sensor_01 type "part" hsetprop ${scobj_hpath}/sensor_01 nxalias "${name}_sensor_01" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/sensor_01 60 + hsetprop ${scobj_hpath}/sensor_01 simulated false + } else { + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" + hsetprop ${scobj_hpath}/sensor_01 simulated true + } + hfactory ${scobj_hpath}/sensor_02 plain user float hsetprop ${scobj_hpath}/sensor_02 read ${ns}::getSensor ${scobj_hpath} readSensor {2} hsetprop ${scobj_hpath}/sensor_02 readSensor ${ns}::readSensor ${scobj_hpath} @@ -243,6 +262,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/sensor_02 type "part" hsetprop ${scobj_hpath}/sensor_02 nxalias "${name}_sensor_02" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/sensor_02 600 + hsetprop ${scobj_hpath}/sensor_02 simulated false + } else { + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" + hsetprop ${scobj_hpath}/sensor_02 simulated true + } + hfactory ${scobj_hpath}/sensor_03 plain user float hsetprop ${scobj_hpath}/sensor_03 read ${ns}::getSensor ${scobj_hpath} readSensor {3} hsetprop ${scobj_hpath}/sensor_03 readSensor ${ns}::readSensor ${scobj_hpath} @@ -256,6 +283,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/sensor_03 type "part" hsetprop ${scobj_hpath}/sensor_03 nxalias "${name}_sensor_03" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/sensor_03 600 + hsetprop ${scobj_hpath}/sensor_03 simulated false + } else { + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" + hsetprop ${scobj_hpath}/sensor_03 simulated true + } + hfactory ${scobj_hpath}/sensor_04 plain user float hsetprop ${scobj_hpath}/sensor_04 read ${ns}::getSensor ${scobj_hpath} readSensor {4} hsetprop ${scobj_hpath}/sensor_04 readSensor ${ns}::readSensor ${scobj_hpath} @@ -269,6 +304,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/sensor_04 type "part" hsetprop ${scobj_hpath}/sensor_04 nxalias "${name}_sensor_04" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/sensor_04 600 + hsetprop ${scobj_hpath}/sensor_04 simulated false + } else { + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" + hsetprop ${scobj_hpath}/sensor_04 simulated true + } + hfactory ${scobj_hpath}/sensor_05 plain user float hsetprop ${scobj_hpath}/sensor_05 read ${ns}::getSensor ${scobj_hpath} readSensor {5} hsetprop ${scobj_hpath}/sensor_05 readSensor ${ns}::readSensor ${scobj_hpath} @@ -282,6 +325,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/sensor_05 type "part" hsetprop ${scobj_hpath}/sensor_05 nxalias "${name}_sensor_05" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/sensor_05 600 + hsetprop ${scobj_hpath}/sensor_05 simulated false + } else { + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" + hsetprop ${scobj_hpath}/sensor_05 simulated true + } + hfactory ${scobj_hpath}/sensor_06 plain user float hsetprop ${scobj_hpath}/sensor_06 read ${ns}::getSensor ${scobj_hpath} readSensor {6} hsetprop ${scobj_hpath}/sensor_06 readSensor ${ns}::readSensor ${scobj_hpath} @@ -295,6 +346,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/sensor_06 type "part" hsetprop ${scobj_hpath}/sensor_06 nxalias "${name}_sensor_06" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/sensor_06 600 + hsetprop ${scobj_hpath}/sensor_06 simulated false + } else { + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" + hsetprop ${scobj_hpath}/sensor_06 simulated true + } + hfactory ${scobj_hpath}/sensor_07 plain user float hsetprop ${scobj_hpath}/sensor_07 read ${ns}::getSensor ${scobj_hpath} readSensor {7} hsetprop ${scobj_hpath}/sensor_07 readSensor ${ns}::readSensor ${scobj_hpath} @@ -308,6 +367,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/sensor_07 type "part" hsetprop ${scobj_hpath}/sensor_07 nxalias "${name}_sensor_07" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/sensor_07 600 + hsetprop ${scobj_hpath}/sensor_07 simulated false + } else { + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" + hsetprop ${scobj_hpath}/sensor_07 simulated true + } + hfactory ${scobj_hpath}/sensor_08 plain user float hsetprop ${scobj_hpath}/sensor_08 read ${ns}::getSensor ${scobj_hpath} readSensor {8} hsetprop ${scobj_hpath}/sensor_08 readSensor ${ns}::readSensor ${scobj_hpath} @@ -321,23 +388,17 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/sensor_08 type "part" hsetprop ${scobj_hpath}/sensor_08 nxalias "${name}_sensor_08" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/sensor_08 600 + hsetprop ${scobj_hpath}/sensor_08 simulated false + } else { + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" + hsetprop ${scobj_hpath}/sensor_08 simulated true + } + hsetprop ${scobj_hpath} data "true" hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - - if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/id 600 - ${sct_controller} poll ${scobj_hpath}/sensor_01 60 - ${sct_controller} poll ${scobj_hpath}/sensor_02 600 - ${sct_controller} poll ${scobj_hpath}/sensor_03 600 - ${sct_controller} poll ${scobj_hpath}/sensor_04 600 - ${sct_controller} poll ${scobj_hpath}/sensor_05 600 - ${sct_controller} poll ${scobj_hpath}/sensor_06 600 - ${sct_controller} poll ${scobj_hpath}/sensor_07 600 - ${sct_controller} poll ${scobj_hpath}/sensor_08 600 - } else { - ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" - } hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 @@ -358,7 +419,9 @@ proc ::scobj::srs_sr630::add_driver {name device_class simulation_flag ip_addres makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::srs_sr630::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for srs_sr630" + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for srs_sr630" + ::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL } ::scobj::srs_sr630::sics_log 1 "::scobj::srs_sr630::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" ::scobj::srs_sr630::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} @@ -376,7 +439,7 @@ namespace eval ::scobj::srs_sr630 { proc add_srs_sr630 {name ip_address tcp_port} { set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" - ::scobj::srs_sr630::add_driver ${name} "NXdetector" "${simulation_flag}" ${ip_address} ${tcp_port} + ::scobj::srs_sr630::add_driver ${name} "NXdetector" ${simulation_flag} ${ip_address} ${tcp_port} } clientput "file evaluation of sct_srs_sr630.tcl" @@ -415,20 +478,31 @@ proc ::scobj::srs_sr630::read_config {} { 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 "terminator"] } { + 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"]" } } @@ -439,12 +513,9 @@ proc ::scobj::srs_sr630::read_config {} { if { [dict exists $v "timeout"] } { ${asyncqueue} timeout "[dict get $v "timeout"]" } + makesctcontroller sct_${name} aqadapter ${asyncqueue} } - if { [string equal -nocase ${asyncqueue} "sct"] } { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} - } else { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} - } + ${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl b/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl index 2453af03..5a818e53 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl @@ -10,9 +10,12 @@ proc ::scobj::west_6100::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 fd [open "../log/west_6100_[basename ${tc_root}].log" "a"] - set line "[clock format [clock seconds] -format "%T"] ${debug_string}" - puts ${fd} "${line}" + set now [clock seconds] + set ts [clock format ${now} -format "%Y%m%d"] + set log_file_name "../log/west_6100_[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 ] @@ -86,7 +89,12 @@ proc ::scobj::west_6100::checkstatus {tc_root} { # checkstatus hook code goes here if {[sct driving]} { set sp "[sct target]" - set pv "[hval ${tc_root}/[sct driveable]]" + 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] } { @@ -363,6 +371,15 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/alarm1 type "part" hsetprop ${scobj_hpath}/alarm1 nxalias "${name}_alarm1" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/alarm1 1 + ${sct_controller} write ${scobj_hpath}/alarm1 + hsetprop ${scobj_hpath}/alarm1 simulated false + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/alarm1 simulated true + } + hfactory ${scobj_hpath}/alarm2 plain user float hsetprop ${scobj_hpath}/alarm2 read ${ns}::getDecimal ${scobj_hpath} rdDecimal {14} hsetprop ${scobj_hpath}/alarm2 rdDecimal ${ns}::rdDecimal ${scobj_hpath} @@ -379,6 +396,15 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/alarm2 type "part" hsetprop ${scobj_hpath}/alarm2 nxalias "${name}_alarm2" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/alarm2 1 + ${sct_controller} write ${scobj_hpath}/alarm2 + hsetprop ${scobj_hpath}/alarm2 simulated false + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/alarm2 simulated true + } + hfactory ${scobj_hpath}/power plain user int hsetprop ${scobj_hpath}/power read ${ns}::getInteger ${scobj_hpath} rdInteger {3} hsetprop ${scobj_hpath}/power rdInteger ${ns}::rdInteger ${scobj_hpath} @@ -392,6 +418,14 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/power type "part" hsetprop ${scobj_hpath}/power nxalias "${name}_power" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/power 1 + hsetprop ${scobj_hpath}/power simulated false + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/power simulated true + } + hfactory ${scobj_hpath}/powermax plain user int hsetprop ${scobj_hpath}/powermax read ${ns}::getInteger ${scobj_hpath} rdInteger {20} hsetprop ${scobj_hpath}/powermax rdInteger ${ns}::rdInteger ${scobj_hpath} @@ -408,6 +442,15 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/powermax type "part" hsetprop ${scobj_hpath}/powermax nxalias "${name}_powermax" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/powermax 1 + ${sct_controller} write ${scobj_hpath}/powermax + hsetprop ${scobj_hpath}/powermax simulated false + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/powermax simulated true + } + hfactory ${scobj_hpath}/ramprate plain user float hsetprop ${scobj_hpath}/ramprate read ${ns}::getDecimal ${scobj_hpath} rdDecimal {24} hsetprop ${scobj_hpath}/ramprate rdDecimal ${ns}::rdDecimal ${scobj_hpath} @@ -424,6 +467,15 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/ramprate type "part" hsetprop ${scobj_hpath}/ramprate nxalias "${name}_ramprate" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/ramprate 1 + ${sct_controller} write ${scobj_hpath}/ramprate + hsetprop ${scobj_hpath}/ramprate simulated false + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/ramprate simulated true + } + hfactory ${scobj_hpath}/sensor plain user float hsetprop ${scobj_hpath}/sensor read ${ns}::getDecimal ${scobj_hpath} rdDecimal {1} hsetprop ${scobj_hpath}/sensor rdDecimal ${ns}::rdDecimal ${scobj_hpath} @@ -439,6 +491,14 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/sensor type "part" hsetprop ${scobj_hpath}/sensor nxalias "${name}_sensor" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/sensor 1 + hsetprop ${scobj_hpath}/sensor simulated false + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/sensor simulated true + } + hfactory ${scobj_hpath}/setpoint plain user float hsetprop ${scobj_hpath}/setpoint read ${ns}::getDecimal ${scobj_hpath} rdDecimal {2} hsetprop ${scobj_hpath}/setpoint rdDecimal ${ns}::rdDecimal ${scobj_hpath} @@ -466,6 +526,15 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/setpoint type "drivable" hsetprop ${scobj_hpath}/setpoint nxalias "${name}_setpoint" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/setpoint 1 + ${sct_controller} write ${scobj_hpath}/setpoint + hsetprop ${scobj_hpath}/setpoint simulated false + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/setpoint simulated true + } + hfactory ${scobj_hpath}/w_sp plain user float hsetprop ${scobj_hpath}/w_sp read ${ns}::getDecimal ${scobj_hpath} rdDecimal {21} hsetprop ${scobj_hpath}/w_sp rdDecimal ${ns}::rdDecimal ${scobj_hpath} @@ -482,33 +551,21 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/w_sp type "part" hsetprop ${scobj_hpath}/w_sp nxalias "${name}_w_sp" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/w_sp 1 + ${sct_controller} write ${scobj_hpath}/w_sp + hsetprop ${scobj_hpath}/w_sp simulated false + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/w_sp simulated true + } + hsetprop ${scobj_hpath} data "true" hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - - if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/alarm1 1 - ${sct_controller} poll ${scobj_hpath}/alarm2 1 - ${sct_controller} poll ${scobj_hpath}/power 1 - ${sct_controller} poll ${scobj_hpath}/powermax 1 - ${sct_controller} poll ${scobj_hpath}/ramprate 1 - ${sct_controller} poll ${scobj_hpath}/sensor 1 - ${sct_controller} poll ${scobj_hpath}/setpoint 1 - ${sct_controller} poll ${scobj_hpath}/w_sp 1 - ${sct_controller} write ${scobj_hpath}/alarm1 - ${sct_controller} write ${scobj_hpath}/alarm2 - ${sct_controller} write ${scobj_hpath}/powermax - ${sct_controller} write ${scobj_hpath}/ramprate - ${sct_controller} write ${scobj_hpath}/setpoint - ${sct_controller} write ${scobj_hpath}/w_sp - } else { - ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" - } + ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/sensor ${sct_controller} hfactory ${scobj_hpath}/aux plain spy none - hsetprop ${scobj_hpath}/aux data "false" - hsetprop ${scobj_hpath}/aux klass "@none" - hsetprop ${scobj_hpath}/aux type "part" hfactory ${scobj_hpath}/aux/decimal plain user int hsetprop ${scobj_hpath}/aux/decimal read ${ns}::getInteger ${scobj_hpath} rdInteger {18} @@ -523,6 +580,14 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/aux/decimal type "part" hsetprop ${scobj_hpath}/aux/decimal nxalias "${name}_aux_decimal" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/aux/decimal 2 + hsetprop ${scobj_hpath}/aux/decimal simulated false + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/aux/decimal simulated true + } + hfactory ${scobj_hpath}/aux/instatus plain user int hsetprop ${scobj_hpath}/aux/instatus read ${ns}::getInteger ${scobj_hpath} rdInteger {133} hsetprop ${scobj_hpath}/aux/instatus rdInteger ${ns}::rdInteger ${scobj_hpath} @@ -535,6 +600,14 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/aux/instatus type "part" hsetprop ${scobj_hpath}/aux/instatus nxalias "${name}_aux_instatus" + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/aux/instatus 2 + hsetprop ${scobj_hpath}/aux/instatus simulated false + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/aux/instatus simulated true + } + hfactory ${scobj_hpath}/aux/model plain user int hsetprop ${scobj_hpath}/aux/model read ${ns}::getInteger ${scobj_hpath} rdInteger {122} hsetprop ${scobj_hpath}/aux/model rdInteger ${ns}::rdInteger ${scobj_hpath} @@ -548,18 +621,18 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_ hsetprop ${scobj_hpath}/aux/model nxalias "${name}_aux_model" if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/aux/decimal 2 - ${sct_controller} poll ${scobj_hpath}/aux/instatus 2 ${sct_controller} poll ${scobj_hpath}/aux/model 2 + hsetprop ${scobj_hpath}/aux/model simulated false } else { ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" + hsetprop ${scobj_hpath}/aux/model simulated true } + hsetprop ${scobj_hpath}/aux data "false" + hsetprop ${scobj_hpath}/aux klass "@none" + hsetprop ${scobj_hpath}/aux type "part" hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase "${simulation_flag}" "false"]} { - ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/sensor ${sct_controller} - } # mkDriver hook code goes here } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -577,7 +650,9 @@ proc ::scobj::west_6100::add_driver {name device_class simulation_flag ip_addres makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port} } } else { - ::scobj::west_6100::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for west_6100" + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for west_6100" + ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL } ::scobj::west_6100::sics_log 1 "::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" ::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} @@ -595,7 +670,7 @@ namespace eval ::scobj::west_6100 { proc add_west_6100 {name ip_address tcp_port id} { set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - ::scobj::west_6100::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" + ::scobj::west_6100::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id} } clientput "file evaluation of sct_west_6100.tcl" @@ -634,20 +709,31 @@ proc ::scobj::west_6100::read_config {} { 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} modbus_ap ${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 "terminator"] } { + 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"]" } } @@ -658,6 +744,7 @@ proc ::scobj::west_6100::read_config {} { if { [dict exists $v "timeout"] } { ${asyncqueue} timeout "[dict get $v "timeout"]" } + makesctcontroller sct_${name} aqadapter ${asyncqueue} } set arg_list [list] set missing_list [list] @@ -674,11 +761,7 @@ proc ::scobj::west_6100::read_config {} { if { [llength $missing_list] > 0 } { error "$name is missing configuration values $missing_list" } - if { [string equal -nocase ${asyncqueue} "sct"] } { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list - } else { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list - } + ${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/robots/sct_epson_pandp.tcl b/site_ansto/instrument/config/robots/sct_epson_pandp.tcl index 5a3a318d..ae97c235 100644 --- a/site_ansto/instrument/config/robots/sct_epson_pandp.tcl +++ b/site_ansto/instrument/config/robots/sct_epson_pandp.tcl @@ -10,9 +10,12 @@ proc ::scobj::epson_pandp::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 fd [open "../log/epson_pandp_[basename ${tc_root}].log" "a"] - set line "[clock format [clock seconds] -format "%T"] ${debug_string}" - puts ${fd} "${line}" + set now [clock seconds] + set ts [clock format ${now} -format "%Y%m%d"] + set log_file_name "../log/epson_pandp_[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 ] @@ -60,7 +63,7 @@ namespace eval ::scobj::epson_pandp { proc add_epson_pandp {name ip_address tcp_port robot_name} { set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - ::scobj::epson_pandp::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${robot_name}" + ::scobj::epson_pandp::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${robot_name} } clientput "file evaluation of sct_epson_pandp.tcl" @@ -96,34 +99,7 @@ proc ::scobj::epson_pandp::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "epson_pandp"] } { - if { ![string equal -nocase "${simulation_flag}" "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" - } 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] - } - } 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 - 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"]" - } - } + ::scobj::epson_pandp::sics_log 9 "No sctcontroller for epson_pandp" set arg_list [list] set missing_list [list] foreach arg {robot_name} { @@ -139,11 +115,7 @@ proc ::scobj::epson_pandp::read_config {} { if { [llength $missing_list] > 0 } { error "$name is missing configuration values $missing_list" } - if { [string equal -nocase ${asyncqueue} "sct"] } { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list - } else { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list - } + ${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } } } diff --git a/site_ansto/instrument/hipd/util/sics_config.ini b/site_ansto/instrument/hipd/util/sics_config.ini index 28d7c390..4f0cdd40 100644 --- a/site_ansto/instrument/hipd/util/sics_config.ini +++ b/site_ansto/instrument/hipd/util/sics_config.ini @@ -246,6 +246,14 @@ terminator = \r\n tol1 = 1.0 tol2 = 1.0 +[ls370_1] +desc = "Lakeshore 370 Resistance Bridge" +driver = "lakeshore_m370" +imptype = temperature +ip = 10.157.205.42 +port = 4001 +tol = 1.0 + [mercury_scpi_01] desc = "Oxford Mercury temperature controller in Mercury mode" driver = "mercury_scpi" @@ -311,3 +319,4 @@ imptype = temperature ip = 10.157.205.25 port = 502 timeout = 2000 + diff --git a/site_ansto/instrument/hrpd/config/INSTCFCOMMON.TXT b/site_ansto/instrument/hrpd/config/INSTCFCOMMON.TXT index 3db787da..a5cf70a9 100644 --- a/site_ansto/instrument/hrpd/config/INSTCFCOMMON.TXT +++ b/site_ansto/instrument/hrpd/config/INSTCFCOMMON.TXT @@ -16,6 +16,7 @@ config/hmm/hmm_object.tcl config/hmm/hmm_cylindrical_detector_configuration.tcl config/hmm/anstohm_linked.xml config/robots/sct_pickandplace.tcl +config/robots/sct_epson_pandp.tcl config/scan/scan_common_1.hdd config/scan/scan_common_1.tcl config/nexus/nxscripts_common_1.tcl diff --git a/site_ansto/instrument/hrpd/echidna_configuration.tcl b/site_ansto/instrument/hrpd/echidna_configuration.tcl index 975afd82..e677dde9 100644 --- a/site_ansto/instrument/hrpd/echidna_configuration.tcl +++ b/site_ansto/instrument/hrpd/echidna_configuration.tcl @@ -50,6 +50,7 @@ fileeval $cfPath(environment)/sct_protek_common.tcl fileeval $cfPath(environment)/sct_protekmm.tcl fileeval $cfPath(environment)/temperature/west400.tcl fileeval $cfPath(environment)/temperature/sct_west4100.tcl +fileeval $cfPath(environment)/temperature/sct_west_6100.tcl fileeval $cfPath(environment)/temperature/sct_watlow_pm.tcl fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl diff --git a/site_ansto/instrument/kookaburra/config/anticollider/acscript.txt b/site_ansto/instrument/kookaburra/config/anticollider/acscript.txt index 8ab23c54..a2c963ba 100644 --- a/site_ansto/instrument/kookaburra/config/anticollider/acscript.txt +++ b/site_ansto/instrument/kookaburra/config/anticollider/acscript.txt @@ -1,4 +1,9 @@ -# Forbid detector motion when the detector voltage is on -# comment out -- Jing -#forbid {-inf inf} for det when dhv1 in {800 inf} -#forbid {-inf inf} for detoff when dhv1 in {800 inf} +# Prevent m2om encoder from driving into sample holder. +forbid {10 inf} for m2om whenall {m2y in {-inf 200} m2om in {-inf 10}} +forbid {-inf 170} for m2om whenall {m2y in {-inf 200} m2om in {170 inf}} +forbid {-inf inf} for m2om whenall {m2y in {-inf 200} m2om in {11 169}} +forbid {-inf 200} for m2y when m2om in {10 170} + +# Following two rules allow recovery if m2om position has crept above 10 or below 170 +forbid {11 inf} for m2om whenall {m2y in {-inf 200} m2om in {10 11}} +forbid {-inf 169} for m2om whenall {m2y in {-inf 200} m2om in {169 170}} diff --git a/site_ansto/instrument/runsics.py b/site_ansto/instrument/runsics.py index 68102463..df938fb1 100755 --- a/site_ansto/instrument/runsics.py +++ b/site_ansto/instrument/runsics.py @@ -120,7 +120,7 @@ def stop_cmd(server, args): print 'Failed again!' print "Terminating PID %d with EXTREME PREJUDICE (-15)" % (pid) subprocess.call(shlex.split('sudo -u %s /bin/kill -15 %d' % - sics_killer, (pid))) + (sics_killer, pid))) else: return if status_cmd(server, args) != (0,0): diff --git a/site_ansto/instrument/sans/config/hmm/hmm_configuration.tcl b/site_ansto/instrument/sans/config/hmm/hmm_configuration.tcl index 8a619d2e..c34715e7 100644 --- a/site_ansto/instrument/sans/config/hmm/hmm_configuration.tcl +++ b/site_ansto/instrument/sans/config/hmm/hmm_configuration.tcl @@ -64,6 +64,26 @@ proc ::histogram_memory::isc_initialize {} { } } +# Returns 0 If all trips acknowledged, -n if n trips unacknowledged, +n if too many acks? +::utility::macro::getset float ::histogram_memory::reset_trip {args} { + set num_trips [ SplitReply [hmm configure detector_protect_num_trip] ] + set num_acks [ SplitReply [hmm configure detector_protect_num_trip_ack] ] + set trip_cnt_diff [expr {$num_acks - $num_trips}] + if {$args == ""} { + return "reset_trip = $trip_cnt_diff" + } else { + if {$trip_cnt_diff != 0} { + hmm configure fat_detector_protect_num_trip_ack $num_trips + hmm astop + wait 2 + hmm init + } + } +} +sicslist setatt ::histogram_memory::reset_trip klass detector +sicslist setatt ::histogram_memory::reset_trip long_name reset_trip +sicslist setatt ::histogram_memory::reset_trip data false + proc histmem {cmd args} { eval "_histmem $cmd $args" }