diff --git a/site_ansto/instrument/bilby/config/chopper/astrium_chopper_sct.tcl b/site_ansto/instrument/bilby/config/chopper/astrium_chopper_sct.tcl index b01e07d2..b4b6d368 100644 --- a/site_ansto/instrument/bilby/config/chopper/astrium_chopper_sct.tcl +++ b/site_ansto/instrument/bilby/config/chopper/astrium_chopper_sct.tcl @@ -238,14 +238,14 @@ proc ::scobj::astrium_chopper::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::astrium_chopper::sics_log 9 "::scobj::astrium_chopper::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::astrium_chopper::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::astrium_chopper::sics_log 9 "::scobj::astrium_chopper::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass NXdisk_chopper + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -335,10 +335,10 @@ proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/disk_1/state type "part" hsetprop ${scobj_hpath}/disk_1/state nxalias "${name}_disk_1_state" - if {[string equal -nocase [SplitReply [chopper_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/disk_1/state 1 } else { - ::scobj::astrium_chopper::sics_log 9 "[chopper_simulation] => No poll/write for astrium_chopper" + ::scobj::astrium_chopper::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for astrium_chopper" } hfactory ${scobj_hpath}/disk_2 plain spy none @@ -426,10 +426,10 @@ proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/disk_2/state type "part" hsetprop ${scobj_hpath}/disk_2/state nxalias "${name}_disk_2_state" - if {[string equal -nocase [SplitReply [chopper_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/disk_2/state 1 } else { - ::scobj::astrium_chopper::sics_log 9 "[chopper_simulation] => No poll/write for astrium_chopper" + ::scobj::astrium_chopper::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for astrium_chopper" } hfactory ${scobj_hpath}/disk_3 plain spy none @@ -517,10 +517,10 @@ proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/disk_3/state type "part" hsetprop ${scobj_hpath}/disk_3/state nxalias "${name}_disk_3_state" - if {[string equal -nocase [SplitReply [chopper_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/disk_3/state 1 } else { - ::scobj::astrium_chopper::sics_log 9 "[chopper_simulation] => No poll/write for astrium_chopper" + ::scobj::astrium_chopper::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for astrium_chopper" } hfactory ${scobj_hpath}/disk_4 plain spy none @@ -608,12 +608,12 @@ proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/disk_4/state type "part" hsetprop ${scobj_hpath}/disk_4/state nxalias "${name}_disk_4_state" - if {[string equal -nocase [SplitReply [chopper_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/disk_4/state 1 } else { - ::scobj::astrium_chopper::sics_log 9 "[chopper_simulation] => No poll/write for astrium_chopper" + ::scobj::astrium_chopper::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for astrium_chopper" } - hsetprop ${scobj_hpath} klass NXdisk_chopper + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -622,43 +622,51 @@ proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_por handle_exception ${catch_status} ${catch_message} } +proc ::scobj::astrium_chopper::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::astrium_chopper::sics_log 9 "::scobj::astrium_chopper::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::astrium_chopper::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::astrium_chopper::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::astrium_chopper::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for astrium_chopper" + ::scobj::astrium_chopper::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::astrium_chopper::sics_log 1 "::scobj::astrium_chopper::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::astrium_chopper::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::astrium_chopper { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_astrium_chopper {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::astrium_chopper::sics_log 9 "add_astrium_chopper ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [chopper_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::astrium_chopper::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::astrium_chopper::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::astrium_chopper::sics_log 9 "[chopper_simulation] => Null sctcontroller for astrium_chopper" - ::scobj::astrium_chopper::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::astrium_chopper::sics_log 1 "::scobj::astrium_chopper::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::astrium_chopper::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [chopper_simulation]]]" + ::scobj::astrium_chopper::add_driver ${name} "NXdisk_chopper" "${simulation_flag}" ${ip_address} ${tcp_port} } -clientput "file evaluation of astrium_chopper_sct.tcl" -::scobj::astrium_chopper::sics_log 9 "file evaluation of astrium_chopper_sct.tcl" +clientput "file evaluation of sct_astrium_chopper.tcl" +::scobj::astrium_chopper::sics_log 9 "file evaluation of sct_astrium_chopper.tcl" proc ::scobj::astrium_chopper::read_config {} { set catch_status [ catch { set ns "::scobj::astrium_chopper" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [chopper_simulation]]]" + set device_class "NXdisk_chopper" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -666,6 +674,12 @@ proc ::scobj::astrium_chopper::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -676,9 +690,9 @@ proc ::scobj::astrium_chopper::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "astrium_chopper"] } { - if { ![string equal -nocase [SplitReply [chopper_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[chopper_simulation] => using null asyncqueue" + ${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"] } { @@ -705,9 +719,9 @@ proc ::scobj::astrium_chopper::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_astrium_chopper ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_astrium_chopper ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/bilby/config/motors/shutters_sct.tcl b/site_ansto/instrument/bilby/config/motors/shutters_sct.tcl index a369764c..d189a36c 100644 --- a/site_ansto/instrument/bilby/config/motors/shutters_sct.tcl +++ b/site_ansto/instrument/bilby/config/motors/shutters_sct.tcl @@ -193,14 +193,14 @@ proc ::scobj::shutters::write_switch {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::shutters::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::shutters::sics_log 9 "::scobj::shutters::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::shutters::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::shutters::sics_log 9 "::scobj::shutters::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass instrument + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -257,16 +257,16 @@ proc ::scobj::shutters::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} nxsave "true" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/fast_shutter 1 ${sct_controller} poll ${scobj_hpath}/rough_100 1 ${sct_controller} poll ${scobj_hpath}/rough_40 1 ${sct_controller} write ${scobj_hpath}/rough_100 ${sct_controller} write ${scobj_hpath}/rough_40 } else { - ::scobj::shutters::sics_log 9 "[motor_simulation] => No poll/write for shutters" + ::scobj::shutters::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for shutters" } - hsetprop ${scobj_hpath} klass instrument + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -275,43 +275,51 @@ proc ::scobj::shutters::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::shutters::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::shutters::sics_log 9 "::scobj::shutters::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::shutters::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::shutters::sics_log 9 "makesctcontroller sct_${name} dmc2280 ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} dmc2280 ${ip_address}:${tcp_port} + } + } else { + ::scobj::shutters::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for shutters" + ::scobj::shutters::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::shutters::sics_log 1 "::scobj::shutters::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::shutters::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::shutters { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_shutters {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::shutters::sics_log 9 "add_shutters ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::shutters::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::shutters::sics_log 9 "makesctcontroller sct_${name} dmc2280 ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} dmc2280 ${ip_address}:${tcp_port} - } - } else { - ::scobj::shutters::sics_log 9 "[motor_simulation] => Null sctcontroller for shutters" - ::scobj::shutters::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::shutters::sics_log 1 "::scobj::shutters::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::shutters::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [motor_simulation]]]" + ::scobj::shutters::add_driver ${name} "instrument" "${simulation_flag}" ${ip_address} ${tcp_port} } -clientput "file evaluation of shutters_sct.tcl" -::scobj::shutters::sics_log 9 "file evaluation of shutters_sct.tcl" +clientput "file evaluation of sct_shutters.tcl" +::scobj::shutters::sics_log 9 "file evaluation of sct_shutters.tcl" proc ::scobj::shutters::read_config {} { set catch_status [ catch { set ns "::scobj::shutters" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [motor_simulation]]]" + set device_class "instrument" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -319,6 +327,12 @@ proc ::scobj::shutters::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -329,9 +343,9 @@ proc ::scobj::shutters::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "shutters"] } { - if { ![string equal -nocase [SplitReply [motor_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[motor_simulation] => using null asyncqueue" + ${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"] } { @@ -358,9 +372,9 @@ proc ::scobj::shutters::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_shutters ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_shutters ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/bilby/config/motors/tank_sct.tcl b/site_ansto/instrument/bilby/config/motors/tank_sct.tcl index fd278ad8..0dd7d9a5 100644 --- a/site_ansto/instrument/bilby/config/motors/tank_sct.tcl +++ b/site_ansto/instrument/bilby/config/motors/tank_sct.tcl @@ -201,14 +201,14 @@ proc ::scobj::tank::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::tank::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::tank::sics_log 9 "::scobj::tank::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::tank::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::tank::sics_log 9 "::scobj::tank::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass instrument + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -230,10 +230,10 @@ proc ::scobj::tank::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/pos 1 } else { - ::scobj::tank::sics_log 9 "[motor_simulation] => No poll/write for tank" + ::scobj::tank::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tank" } hfactory ${scobj_hpath}/limits plain spy none @@ -267,11 +267,11 @@ proc ::scobj::tank::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath}/limits/reverse type "part" hsetprop ${scobj_hpath}/limits/reverse nxalias "${name}_limits_reverse" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/limits/forward 1 ${sct_controller} poll ${scobj_hpath}/limits/reverse 1 } else { - ::scobj::tank::sics_log 9 "[motor_simulation] => No poll/write for tank" + ::scobj::tank::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tank" } hfactory ${scobj_hpath}/switches plain spy none @@ -305,13 +305,13 @@ proc ::scobj::tank::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath}/switches/reverse type "part" hsetprop ${scobj_hpath}/switches/reverse nxalias "${name}_switches_reverse" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/switches/forward 1 ${sct_controller} poll ${scobj_hpath}/switches/reverse 1 } else { - ::scobj::tank::sics_log 9 "[motor_simulation] => No poll/write for tank" + ::scobj::tank::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tank" } - hsetprop ${scobj_hpath} klass instrument + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -323,17 +323,10 @@ proc ::scobj::tank::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::tank { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_tank {name ip_address tcp_port} { +proc ::scobj::tank::add_driver {name device_class simulation_flag ip_address tcp_port} { set catch_status [ catch { - ::scobj::tank::sics_log 9 "add_tank ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { + ::scobj::tank::sics_log 9 "::scobj::tank::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::tank::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -342,24 +335,39 @@ proc add_tank {name ip_address tcp_port} { makesctcontroller sct_${name} dmc2280 ${ip_address}:${tcp_port} } } else { - ::scobj::tank::sics_log 9 "[motor_simulation] => Null sctcontroller for tank" + ::scobj::tank::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for tank" ::scobj::tank::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::tank::sics_log 1 "::scobj::tank::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::tank::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} + ::scobj::tank::sics_log 1 "::scobj::tank::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::tank::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of tank_sct.tcl" -::scobj::tank::sics_log 9 "file evaluation of tank_sct.tcl" +namespace eval ::scobj::tank { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_tank {name ip_address tcp_port} { + set simulation_flag "[string tolower [SplitReply [motor_simulation]]]" + ::scobj::tank::add_driver ${name} "instrument" "${simulation_flag}" ${ip_address} ${tcp_port} +} + +clientput "file evaluation of sct_tank.tcl" +::scobj::tank::sics_log 9 "file evaluation of sct_tank.tcl" proc ::scobj::tank::read_config {} { set catch_status [ catch { set ns "::scobj::tank" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [motor_simulation]]]" + set device_class "instrument" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -367,6 +375,12 @@ proc ::scobj::tank::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -377,9 +391,9 @@ proc ::scobj::tank::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "tank"] } { - if { ![string equal -nocase [SplitReply [motor_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[motor_simulation] => using null asyncqueue" + ${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"] } { @@ -406,9 +420,9 @@ proc ::scobj::tank::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_tank ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_tank ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/agilent_33220A_sct.tcl b/site_ansto/instrument/config/environment/agilent_33220A_sct.tcl index 363371d9..1b335090 100644 --- a/site_ansto/instrument/config/environment/agilent_33220A_sct.tcl +++ b/site_ansto/instrument/config/environment/agilent_33220A_sct.tcl @@ -63,8 +63,8 @@ proc add_agilent_33220A {name ip_address tcp_port} { ::scobj::agilent_33220A::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} } -clientput "file evaluation of agilent_33220A_sct.tcl" -::scobj::agilent_33220A::sics_log 9 "file evaluation of agilent_33220A_sct.tcl" +clientput "file evaluation of sct_agilent_33220A.tcl" +::scobj::agilent_33220A::sics_log 9 "file evaluation of sct_agilent_33220A.tcl" proc ::scobj::agilent_33220A::read_config {} { set catch_status [ catch { diff --git a/site_ansto/instrument/config/environment/hiden_xcs_sct.tcl b/site_ansto/instrument/config/environment/hiden_xcs_sct.tcl index 81c275b6..d42c1544 100644 --- a/site_ansto/instrument/config/environment/hiden_xcs_sct.tcl +++ b/site_ansto/instrument/config/environment/hiden_xcs_sct.tcl @@ -745,14 +745,14 @@ proc ::scobj::hiden_xcs::write_twelve {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } { - ::scobj::hiden_xcs::sics_log 9 "::scobj::hiden_xcs::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id}" +proc ::scobj::hiden_xcs::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id } { + ::scobj::hiden_xcs::sics_log 9 "::scobj::hiden_xcs::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -837,11 +837,11 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } hsetprop ${scobj_hpath} nxsave "true" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/enabled 10 ${sct_controller} write ${scobj_hpath}/enabled } else { - ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs" + ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" } hfactory ${scobj_hpath}/analog plain spy none @@ -984,7 +984,7 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } hsetprop ${scobj_hpath}/analog/sp3 type "part" hsetprop ${scobj_hpath}/analog/sp3 nxalias "${name}_analog_sp3" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/ansto_temp 5 ${sct_controller} poll ${scobj_hpath}/analog/pv1 5 ${sct_controller} poll ${scobj_hpath}/analog/pv2 5 @@ -998,7 +998,7 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } ${sct_controller} write ${scobj_hpath}/analog/sp2 ${sct_controller} write ${scobj_hpath}/analog/sp3 } else { - ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs" + ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" } hfactory ${scobj_hpath}/flow plain spy none @@ -1054,11 +1054,11 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } hsetprop ${scobj_hpath}/flow/setpoint type "drivable" hsetprop ${scobj_hpath}/flow/setpoint nxalias "${name}_flow_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/flow/sensor 1 ${sct_controller} write ${scobj_hpath}/flow/setpoint } else { - ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs" + ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" } hfactory ${scobj_hpath}/humidity plain spy none @@ -1114,16 +1114,16 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } hsetprop ${scobj_hpath}/humidity/setpoint type "drivable" hsetprop ${scobj_hpath}/humidity/setpoint nxalias "${name}_humidity_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/humidity/sensor 1 ${sct_controller} write ${scobj_hpath}/humidity/setpoint } else { - ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs" + ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_flow_setpoint ${scobj_hpath}/flow/setpoint ${scobj_hpath}/flow/sensor ${sct_controller} ansto_makesctdrive ${name}_humidity_setpoint ${scobj_hpath}/humidity/setpoint ${scobj_hpath}/humidity/sensor ${sct_controller} } @@ -1133,17 +1133,10 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::hiden_xcs { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_hiden_xcs {name ip_address tcp_port id} { +proc ::scobj::hiden_xcs::add_driver {name device_class simulation_flag ip_address tcp_port id} { set catch_status [ catch { - ::scobj::hiden_xcs::sics_log 9 "add_hiden_xcs ${name} ${ip_address} ${tcp_port} ${id}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::hiden_xcs::sics_log 9 "::scobj::hiden_xcs::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::hiden_xcs::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -1152,24 +1145,39 @@ proc add_hiden_xcs {name ip_address tcp_port id} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => Null sctcontroller for hiden_xcs" + ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for hiden_xcs" ::scobj::hiden_xcs::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::hiden_xcs::sics_log 1 "::scobj::hiden_xcs::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id}" - ::scobj::hiden_xcs::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} + ::scobj::hiden_xcs::sics_log 1 "::scobj::hiden_xcs::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + ::scobj::hiden_xcs::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of hiden_xcs_sct.tcl" -::scobj::hiden_xcs::sics_log 9 "file evaluation of hiden_xcs_sct.tcl" +namespace eval ::scobj::hiden_xcs { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_hiden_xcs {name ip_address tcp_port id} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::hiden_xcs::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" +} + +clientput "file evaluation of sct_hiden_xcs.tcl" +::scobj::hiden_xcs::sics_log 9 "file evaluation of sct_hiden_xcs.tcl" proc ::scobj::hiden_xcs::read_config {} { set catch_status [ catch { set ns "::scobj::hiden_xcs" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -1177,6 +1185,12 @@ proc ::scobj::hiden_xcs::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -1187,9 +1201,9 @@ proc ::scobj::hiden_xcs::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "hiden_xcs"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -1231,9 +1245,9 @@ proc ::scobj::hiden_xcs::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_hiden_xcs ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_hiden_xcs ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/huber_pilot_sct.tcl b/site_ansto/instrument/config/environment/huber_pilot_sct.tcl index b50ecd4d..ffdbafe2 100644 --- a/site_ansto/instrument/config/environment/huber_pilot_sct.tcl +++ b/site_ansto/instrument/config/environment/huber_pilot_sct.tcl @@ -287,8 +287,8 @@ proc ::scobj::huber_pilot::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::huber_pilot::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::huber_pilot::sics_log 9 "::scobj::huber_pilot::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::huber_pilot::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::huber_pilot::sics_log 9 "::scobj::huber_pilot::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { @@ -296,7 +296,7 @@ proc ::scobj::huber_pilot::mkDriver { sct_controller name ip_address tcp_port } MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -415,7 +415,7 @@ proc ::scobj::huber_pilot::mkDriver { sct_controller name ip_address tcp_port } hsetprop ${scobj_hpath}/Loop1/vTmpMode type "part" hsetprop ${scobj_hpath}/Loop1/vTmpMode nxalias "${name}_Loop1_vTmpMode" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop1/sensor_int 1 ${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 1 ${sct_controller} poll ${scobj_hpath}/Loop1/vMaxSP 1 @@ -425,12 +425,12 @@ proc ::scobj::huber_pilot::mkDriver { sct_controller name ip_address tcp_port } ${sct_controller} poll ${scobj_hpath}/Loop1/vTmpMode 1 ${sct_controller} write ${scobj_hpath}/Loop1/setpoint } else { - ::scobj::huber_pilot::sics_log 9 "[environment_simulation] => No poll/write for huber_pilot" + ::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for huber_pilot" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor_int ${sct_controller} } # mkDriver hook code goes here @@ -438,43 +438,51 @@ proc ::scobj::huber_pilot::mkDriver { sct_controller name ip_address tcp_port } handle_exception ${catch_status} ${catch_message} } +proc ::scobj::huber_pilot::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::huber_pilot::sics_log 9 "::scobj::huber_pilot::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for huber_pilot" + ::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::huber_pilot::sics_log 1 "::scobj::huber_pilot::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::huber_pilot::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::huber_pilot { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_huber_pilot {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::huber_pilot::sics_log 9 "add_huber_pilot ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::huber_pilot::sics_log 9 "[environment_simulation] => Null sctcontroller for huber_pilot" - ::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::huber_pilot::sics_log 1 "::scobj::huber_pilot::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::huber_pilot::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::huber_pilot::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} } -clientput "file evaluation of huber_pilot_sct.tcl" -::scobj::huber_pilot::sics_log 9 "file evaluation of huber_pilot_sct.tcl" +clientput "file evaluation of sct_huber_pilot.tcl" +::scobj::huber_pilot::sics_log 9 "file evaluation of sct_huber_pilot.tcl" proc ::scobj::huber_pilot::read_config {} { set catch_status [ catch { set ns "::scobj::huber_pilot" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -482,6 +490,12 @@ proc ::scobj::huber_pilot::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -492,9 +506,9 @@ proc ::scobj::huber_pilot::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "huber_pilot"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -521,9 +535,9 @@ proc ::scobj::huber_pilot::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_huber_pilot ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_huber_pilot ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/isotech_ps_sct.tcl b/site_ansto/instrument/config/environment/isotech_ps_sct.tcl index 25c173ea..b8a36ecf 100644 --- a/site_ansto/instrument/config/environment/isotech_ps_sct.tcl +++ b/site_ansto/instrument/config/environment/isotech_ps_sct.tcl @@ -240,14 +240,14 @@ proc ::scobj::isotech_ps::write_voltage {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::isotech_ps::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::isotech_ps::sics_log 9 "::scobj::isotech_ps::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::isotech_ps::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::isotech_ps::sics_log 9 "::scobj::isotech_ps::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -303,16 +303,16 @@ proc ::scobj::isotech_ps::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/amps 5 ${sct_controller} poll ${scobj_hpath}/relay 5 ${sct_controller} poll ${scobj_hpath}/volts 5 ${sct_controller} write ${scobj_hpath}/relay ${sct_controller} write ${scobj_hpath}/volts } else { - ::scobj::isotech_ps::sics_log 9 "[environment_simulation] => No poll/write for isotech_ps" + ::scobj::isotech_ps::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for isotech_ps" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -320,43 +320,51 @@ proc ::scobj::isotech_ps::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::isotech_ps::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::isotech_ps::sics_log 9 "::scobj::isotech_ps::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port} \"\\r\"" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} "\r" + } + } else { + ::scobj::isotech_ps::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for isotech_ps" + ::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::isotech_ps::sics_log 1 "::scobj::isotech_ps::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::isotech_ps::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::isotech_ps { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_isotech_ps {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::isotech_ps::sics_log 9 "add_isotech_ps ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port} \"\\r\"" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} "\r" - } - } else { - ::scobj::isotech_ps::sics_log 9 "[environment_simulation] => Null sctcontroller for isotech_ps" - ::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::isotech_ps::sics_log 1 "::scobj::isotech_ps::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::isotech_ps::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::isotech_ps::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} } -clientput "file evaluation of isotech_ps_sct.tcl" -::scobj::isotech_ps::sics_log 9 "file evaluation of isotech_ps_sct.tcl" +clientput "file evaluation of sct_isotech_ps.tcl" +::scobj::isotech_ps::sics_log 9 "file evaluation of sct_isotech_ps.tcl" proc ::scobj::isotech_ps::read_config {} { set catch_status [ catch { set ns "::scobj::isotech_ps" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -364,6 +372,12 @@ proc ::scobj::isotech_ps::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -374,9 +388,9 @@ proc ::scobj::isotech_ps::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "isotech_ps"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -403,9 +417,9 @@ proc ::scobj::isotech_ps::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_isotech_ps ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_isotech_ps ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/keithley_m2700_sct.tcl b/site_ansto/instrument/config/environment/keithley_m2700_sct.tcl index a6647568..a8194864 100644 --- a/site_ansto/instrument/config/environment/keithley_m2700_sct.tcl +++ b/site_ansto/instrument/config/environment/keithley_m2700_sct.tcl @@ -27,18 +27,18 @@ proc ::scobj::keithley_m2700::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::keithley_m2700::mkDriver { sct_controller name ip_address tcp_port id datype tol } { - ::scobj::keithley_m2700::sics_log 9 "::scobj::keithley_m2700::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" +proc ::scobj::keithley_m2700::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype tol } { + ::scobj::keithley_m2700::sics_log 9 "::scobj::keithley_m2700::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::keithley_m2700::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::keithley_m2700 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_keithley_m2700 {name ip_address tcp_port id datype tol} { +proc ::scobj::keithley_m2700::add_driver {name device_class simulation_flag ip_address tcp_port id datype tol} { set catch_status [ catch { - ::scobj::keithley_m2700::sics_log 9 "add_keithley_m2700 ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::keithley_m2700::sics_log 9 "::scobj::keithley_m2700::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::keithley_m2700::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,24 +60,39 @@ proc add_keithley_m2700 {name ip_address tcp_port id datype tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::keithley_m2700::sics_log 9 "[environment_simulation] => Null sctcontroller for keithley_m2700" + ::scobj::keithley_m2700::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for keithley_m2700" ::scobj::keithley_m2700::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::keithley_m2700::sics_log 1 "::scobj::keithley_m2700::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" - ::scobj::keithley_m2700::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol} + ::scobj::keithley_m2700::sics_log 1 "::scobj::keithley_m2700::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" + ::scobj::keithley_m2700::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of keithley_m2700_sct.tcl" -::scobj::keithley_m2700::sics_log 9 "file evaluation of keithley_m2700_sct.tcl" +namespace eval ::scobj::keithley_m2700 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_keithley_m2700 {name ip_address tcp_port id datype tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::keithley_m2700::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${tol}" +} + +clientput "file evaluation of sct_keithley_m2700.tcl" +::scobj::keithley_m2700::sics_log 9 "file evaluation of sct_keithley_m2700.tcl" proc ::scobj::keithley_m2700::read_config {} { set catch_status [ catch { set ns "::scobj::keithley_m2700" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -92,6 +100,12 @@ proc ::scobj::keithley_m2700::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -102,9 +116,9 @@ proc ::scobj::keithley_m2700::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "keithley_m2700"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -146,9 +160,9 @@ proc ::scobj::keithley_m2700::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_keithley_m2700 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_keithley_m2700 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/magneticField/green_magnet_labview_sct.tcl b/site_ansto/instrument/config/environment/magneticField/green_magnet_labview_sct.tcl index 1104d82a..d7fa10d9 100644 --- a/site_ansto/instrument/config/environment/magneticField/green_magnet_labview_sct.tcl +++ b/site_ansto/instrument/config/environment/magneticField/green_magnet_labview_sct.tcl @@ -69,8 +69,8 @@ proc add_green_magnet_labview {name ip_address tcp_port} { ::scobj::green_magnet_labview::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} } -clientput "file evaluation of green_magnet_labview_sct.tcl" -::scobj::green_magnet_labview::sics_log 9 "file evaluation of green_magnet_labview_sct.tcl" +clientput "file evaluation of sct_green_magnet_labview.tcl" +::scobj::green_magnet_labview::sics_log 9 "file evaluation of sct_green_magnet_labview.tcl" proc ::scobj::green_magnet_labview::read_config {} { set catch_status [ catch { diff --git a/site_ansto/instrument/config/environment/magneticField/oxford12tlv_sct.tcl b/site_ansto/instrument/config/environment/magneticField/oxford12tlv_sct.tcl index f21671de..a9848bc8 100644 --- a/site_ansto/instrument/config/environment/magneticField/oxford12tlv_sct.tcl +++ b/site_ansto/instrument/config/environment/magneticField/oxford12tlv_sct.tcl @@ -27,18 +27,18 @@ proc ::scobj::oxford12tlv::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::oxford12tlv::mkDriver { sct_controller name ip_address tcp_port id datype interval } { - ::scobj::oxford12tlv::sics_log 9 "::scobj::oxford12tlv::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" +proc ::scobj::oxford12tlv::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype interval } { + ::scobj::oxford12tlv::sics_log 9 "::scobj::oxford12tlv::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -53,17 +53,10 @@ proc ::scobj::oxford12tlv::mkDriver { sct_controller name ip_address tcp_port id handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::oxford12tlv { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_oxford12tlv {name ip_address tcp_port id datype interval} { +proc ::scobj::oxford12tlv::add_driver {name device_class simulation_flag ip_address tcp_port id datype interval} { set catch_status [ catch { - ::scobj::oxford12tlv::sics_log 9 "add_oxford12tlv ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::oxford12tlv::sics_log 9 "::scobj::oxford12tlv::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::oxford12tlv::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -72,24 +65,39 @@ proc add_oxford12tlv {name ip_address tcp_port id datype interval} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::oxford12tlv::sics_log 9 "[environment_simulation] => Null sctcontroller for oxford12tlv" + ::scobj::oxford12tlv::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for oxford12tlv" ::scobj::oxford12tlv::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::oxford12tlv::sics_log 1 "::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" - ::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${interval} + ::scobj::oxford12tlv::sics_log 1 "::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" + ::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${interval} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of oxford12tlv_sct.tcl" -::scobj::oxford12tlv::sics_log 9 "file evaluation of oxford12tlv_sct.tcl" +namespace eval ::scobj::oxford12tlv { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_oxford12tlv {name ip_address tcp_port id datype interval} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::oxford12tlv::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${interval}" +} + +clientput "file evaluation of sct_oxford12tlv.tcl" +::scobj::oxford12tlv::sics_log 9 "file evaluation of sct_oxford12tlv.tcl" proc ::scobj::oxford12tlv::read_config {} { set catch_status [ catch { set ns "::scobj::oxford12tlv" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -97,6 +105,12 @@ proc ::scobj::oxford12tlv::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -107,9 +121,9 @@ proc ::scobj::oxford12tlv::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "oxford12tlv"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -151,9 +165,9 @@ proc ::scobj::oxford12tlv::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_oxford12tlv ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_oxford12tlv ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/magneticField/tsi_smc_sct.tcl b/site_ansto/instrument/config/environment/magneticField/tsi_smc_sct.tcl index d2200d91..7e20af72 100644 --- a/site_ansto/instrument/config/environment/magneticField/tsi_smc_sct.tcl +++ b/site_ansto/instrument/config/environment/magneticField/tsi_smc_sct.tcl @@ -263,14 +263,14 @@ proc ::scobj::tsi_smc::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { - ::scobj::tsi_smc::sics_log 9 "::scobj::tsi_smc::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id}" +proc ::scobj::tsi_smc::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id } { + ::scobj::tsi_smc::sics_log 9 "::scobj::tsi_smc::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -320,10 +320,10 @@ proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} write ${scobj_hpath}/setpoint } else { - ::scobj::tsi_smc::sics_log 9 "[environment_simulation] => No poll/write for tsi_smc" + ::scobj::tsi_smc::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tsi_smc" } hfactory ${scobj_hpath}/a plain spy none @@ -404,7 +404,7 @@ proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { hsetprop ${scobj_hpath}/a/S type "part" hsetprop ${scobj_hpath}/a/S nxalias "${name}_a_S" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/a/G 1 ${sct_controller} poll ${scobj_hpath}/a/J 1 ${sct_controller} poll ${scobj_hpath}/a/K 1 @@ -412,7 +412,7 @@ proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { ${sct_controller} poll ${scobj_hpath}/a/O 1 ${sct_controller} poll ${scobj_hpath}/a/S 1 } else { - ::scobj::tsi_smc::sics_log 9 "[environment_simulation] => No poll/write for tsi_smc" + ::scobj::tsi_smc::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tsi_smc" } hfactory ${scobj_hpath}/b plain spy none @@ -485,18 +485,18 @@ proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { hsetprop ${scobj_hpath}/b/Rate type "part" hsetprop ${scobj_hpath}/b/Rate nxalias "${name}_b_Rate" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} write ${scobj_hpath}/b/Lower ${sct_controller} write ${scobj_hpath}/b/Pause ${sct_controller} write ${scobj_hpath}/b/Ramp ${sct_controller} write ${scobj_hpath}/b/Rate } else { - ::scobj::tsi_smc::sics_log 9 "[environment_simulation] => No poll/write for tsi_smc" + ::scobj::tsi_smc::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tsi_smc" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/value ${sct_controller} } # mkDriver hook code goes here @@ -504,43 +504,51 @@ proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::tsi_smc::add_driver {name device_class simulation_flag ip_address tcp_port {id 1}} { + set catch_status [ catch { + ::scobj::tsi_smc::sics_log 9 "::scobj::tsi_smc::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::tsi_smc::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::tsi_smc::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::tsi_smc::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for tsi_smc" + ::scobj::tsi_smc::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::tsi_smc::sics_log 1 "::scobj::tsi_smc::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + ::scobj::tsi_smc::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::tsi_smc { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_tsi_smc {name ip_address tcp_port {id 1}} { - set catch_status [ catch { - ::scobj::tsi_smc::sics_log 9 "add_tsi_smc ${name} ${ip_address} ${tcp_port} ${id}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::tsi_smc::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::tsi_smc::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::tsi_smc::sics_log 9 "[environment_simulation] => Null sctcontroller for tsi_smc" - ::scobj::tsi_smc::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::tsi_smc::sics_log 1 "::scobj::tsi_smc::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id}" - ::scobj::tsi_smc::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::tsi_smc::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${1}}" } -clientput "file evaluation of tsi_smc_sct.tcl" -::scobj::tsi_smc::sics_log 9 "file evaluation of tsi_smc_sct.tcl" +clientput "file evaluation of sct_tsi_smc.tcl" +::scobj::tsi_smc::sics_log 9 "file evaluation of sct_tsi_smc.tcl" proc ::scobj::tsi_smc::read_config {} { set catch_status [ catch { set ns "::scobj::tsi_smc" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -548,6 +556,12 @@ proc ::scobj::tsi_smc::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -558,9 +572,9 @@ proc ::scobj::tsi_smc::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "tsi_smc"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -602,9 +616,9 @@ proc ::scobj::tsi_smc::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_tsi_smc ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_tsi_smc ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/nhq_200_sct.tcl b/site_ansto/instrument/config/environment/nhq_200_sct.tcl index 5c6b3413..c8064467 100644 --- a/site_ansto/instrument/config/environment/nhq_200_sct.tcl +++ b/site_ansto/instrument/config/environment/nhq_200_sct.tcl @@ -269,14 +269,14 @@ proc ::scobj::nhq_200::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::nhq_200::sics_log 9 "::scobj::nhq_200::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::nhq_200::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::nhq_200::sics_log 9 "::scobj::nhq_200::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -311,11 +311,11 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/break 10 ${sct_controller} poll ${scobj_hpath}/id 10 } else { - ::scobj::nhq_200::sics_log 9 "[environment_simulation] => No poll/write for nhq_200" + ::scobj::nhq_200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for nhq_200" } hfactory ${scobj_hpath}/ch1 plain spy none @@ -488,7 +488,7 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath}/ch1/voltage type "part" hsetprop ${scobj_hpath}/ch1/voltage nxalias "${name}_ch1_voltage" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/ch1/auto_start 5 ${sct_controller} poll ${scobj_hpath}/ch1/current 5 ${sct_controller} poll ${scobj_hpath}/ch1/i_lim 5 @@ -505,7 +505,7 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { ${sct_controller} write ${scobj_hpath}/ch1/v_ramp ${sct_controller} write ${scobj_hpath}/ch1/v_sp } else { - ::scobj::nhq_200::sics_log 9 "[environment_simulation] => No poll/write for nhq_200" + ::scobj::nhq_200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for nhq_200" } hfactory ${scobj_hpath}/ch2 plain spy none @@ -678,7 +678,7 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath}/ch2/voltage type "part" hsetprop ${scobj_hpath}/ch2/voltage nxalias "${name}_ch2_voltage" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/ch2/auto_start 5 ${sct_controller} poll ${scobj_hpath}/ch2/current 5 ${sct_controller} poll ${scobj_hpath}/ch2/i_lim 5 @@ -695,12 +695,12 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { ${sct_controller} write ${scobj_hpath}/ch2/v_ramp ${sct_controller} write ${scobj_hpath}/ch2/v_sp } else { - ::scobj::nhq_200::sics_log 9 "[environment_simulation] => No poll/write for nhq_200" + ::scobj::nhq_200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for nhq_200" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_ch1_v_sp ${scobj_hpath}/ch1/v_sp ${scobj_hpath}/ch1/voltage ${sct_controller} ansto_makesctdrive ${name}_ch2_v_sp ${scobj_hpath}/ch2/v_sp ${scobj_hpath}/ch2/voltage ${sct_controller} } @@ -709,43 +709,51 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::nhq_200::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::nhq_200::sics_log 9 "::scobj::nhq_200::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::nhq_200::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for nhq_200" + ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::nhq_200::sics_log 1 "::scobj::nhq_200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::nhq_200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::nhq_200 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_nhq_200 {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::nhq_200::sics_log 9 "add_nhq_200 ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::nhq_200::sics_log 9 "[environment_simulation] => Null sctcontroller for nhq_200" - ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::nhq_200::sics_log 1 "::scobj::nhq_200::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::nhq_200::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" + ::scobj::nhq_200::add_driver ${name} "NXdetector" "${simulation_flag}" ${ip_address} ${tcp_port} } -clientput "file evaluation of nhq_200_sct.tcl" -::scobj::nhq_200::sics_log 9 "file evaluation of nhq_200_sct.tcl" +clientput "file evaluation of sct_nhq_200.tcl" +::scobj::nhq_200::sics_log 9 "file evaluation of sct_nhq_200.tcl" proc ::scobj::nhq_200::read_config {} { set catch_status [ catch { set ns "::scobj::nhq_200" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" + set device_class "NXdetector" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -753,6 +761,12 @@ proc ::scobj::nhq_200::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -763,9 +777,9 @@ proc ::scobj::nhq_200::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "nhq_200"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -792,9 +806,9 @@ proc ::scobj::nhq_200::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_nhq_200 ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_nhq_200 ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/omron_hldc_sct.tcl b/site_ansto/instrument/config/environment/omron_hldc_sct.tcl index 6d9a9667..24690617 100644 --- a/site_ansto/instrument/config/environment/omron_hldc_sct.tcl +++ b/site_ansto/instrument/config/environment/omron_hldc_sct.tcl @@ -190,14 +190,14 @@ proc ::scobj::omron_hldc::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::omron_hldc::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::omron_hldc::sics_log 9 "::scobj::omron_hldc::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::omron_hldc::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::omron_hldc::sics_log 9 "::scobj::omron_hldc::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -232,13 +232,13 @@ proc ::scobj::omron_hldc::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/distance 1 ${sct_controller} poll ${scobj_hpath}/id 10 } else { - ::scobj::omron_hldc::sics_log 9 "[environment_simulation] => No poll/write for omron_hldc" + ::scobj::omron_hldc::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for omron_hldc" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -246,43 +246,51 @@ proc ::scobj::omron_hldc::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::omron_hldc::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::omron_hldc::sics_log 9 "::scobj::omron_hldc::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::omron_hldc::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::omron_hldc::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::omron_hldc::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for omron_hldc" + ::scobj::omron_hldc::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::omron_hldc::sics_log 1 "::scobj::omron_hldc::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::omron_hldc::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::omron_hldc { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_omron_hldc {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::omron_hldc::sics_log 9 "add_omron_hldc ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::omron_hldc::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::omron_hldc::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::omron_hldc::sics_log 9 "[environment_simulation] => Null sctcontroller for omron_hldc" - ::scobj::omron_hldc::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::omron_hldc::sics_log 1 "::scobj::omron_hldc::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::omron_hldc::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::omron_hldc::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} } -clientput "file evaluation of omron_hldc_sct.tcl" -::scobj::omron_hldc::sics_log 9 "file evaluation of omron_hldc_sct.tcl" +clientput "file evaluation of sct_omron_hldc.tcl" +::scobj::omron_hldc::sics_log 9 "file evaluation of sct_omron_hldc.tcl" proc ::scobj::omron_hldc::read_config {} { set catch_status [ catch { set ns "::scobj::omron_hldc" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -290,6 +298,12 @@ proc ::scobj::omron_hldc::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -300,9 +314,9 @@ proc ::scobj::omron_hldc::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "omron_hldc"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -329,9 +343,9 @@ proc ::scobj::omron_hldc::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_omron_hldc ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_omron_hldc ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/protekmm_sct.tcl b/site_ansto/instrument/config/environment/protekmm_sct.tcl index 97e409c9..f1fda9ee 100644 --- a/site_ansto/instrument/config/environment/protekmm_sct.tcl +++ b/site_ansto/instrument/config/environment/protekmm_sct.tcl @@ -27,18 +27,18 @@ proc ::scobj::protekmm::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::protekmm::mkDriver { sct_controller name ip_address tcp_port id datype } { - ::scobj::protekmm::sics_log 9 "::scobj::protekmm::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype}" +proc ::scobj::protekmm::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype } { + ::scobj::protekmm::sics_log 9 "::scobj::protekmm::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::protekmm::mkDriver { sct_controller name ip_address tcp_port id da handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::protekmm { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_protekmm {name ip_address tcp_port id datype} { +proc ::scobj::protekmm::add_driver {name device_class simulation_flag ip_address tcp_port id datype} { set catch_status [ catch { - ::scobj::protekmm::sics_log 9 "add_protekmm ${name} ${ip_address} ${tcp_port} ${id} ${datype}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::protekmm::sics_log 9 "::scobj::protekmm::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::protekmm::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,24 +60,39 @@ proc add_protekmm {name ip_address tcp_port id datype} { makesctcontroller sct_${name} protek608 ${ip_address}:${tcp_port} } } else { - ::scobj::protekmm::sics_log 9 "[environment_simulation] => Null sctcontroller for protekmm" + ::scobj::protekmm::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for protekmm" ::scobj::protekmm::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::protekmm::sics_log 1 "::scobj::protekmm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype}" - ::scobj::protekmm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} + ::scobj::protekmm::sics_log 1 "::scobj::protekmm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}" + ::scobj::protekmm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of protekmm_sct.tcl" -::scobj::protekmm::sics_log 9 "file evaluation of protekmm_sct.tcl" +namespace eval ::scobj::protekmm { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_protekmm {name ip_address tcp_port id datype} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::protekmm::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" +} + +clientput "file evaluation of sct_protekmm.tcl" +::scobj::protekmm::sics_log 9 "file evaluation of sct_protekmm.tcl" proc ::scobj::protekmm::read_config {} { set catch_status [ catch { set ns "::scobj::protekmm" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -92,6 +100,12 @@ proc ::scobj::protekmm::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -102,9 +116,9 @@ proc ::scobj::protekmm::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "protekmm"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -146,9 +160,9 @@ proc ::scobj::protekmm::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_protekmm ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_protekmm ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/eurotherm_m2000_sct.tcl b/site_ansto/instrument/config/environment/temperature/eurotherm_m2000_sct.tcl index 5d9c1a5a..fdee0377 100644 --- a/site_ansto/instrument/config/environment/temperature/eurotherm_m2000_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/eurotherm_m2000_sct.tcl @@ -27,18 +27,18 @@ proc ::scobj::eurotherm_m2000::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::eurotherm_m2000::mkDriver { sct_controller name ip_address tcp_port id datype dev_id tol } { - ::scobj::eurotherm_m2000::sics_log 9 "::scobj::eurotherm_m2000::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" +proc ::scobj::eurotherm_m2000::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id tol } { + ::scobj::eurotherm_m2000::sics_log 9 "::scobj::eurotherm_m2000::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::eurotherm_m2000::mkDriver { sct_controller name ip_address tcp_por handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::eurotherm_m2000 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_eurotherm_m2000 {name ip_address tcp_port id datype dev_id tol} { +proc ::scobj::eurotherm_m2000::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id tol} { set catch_status [ catch { - ::scobj::eurotherm_m2000::sics_log 9 "add_eurotherm_m2000 ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::eurotherm_m2000::sics_log 9 "::scobj::eurotherm_m2000::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::eurotherm_m2000::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,24 +60,39 @@ proc add_eurotherm_m2000 {name ip_address tcp_port id datype dev_id tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::eurotherm_m2000::sics_log 9 "[environment_simulation] => Null sctcontroller for eurotherm_m2000" + ::scobj::eurotherm_m2000::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for eurotherm_m2000" ::scobj::eurotherm_m2000::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::eurotherm_m2000::sics_log 1 "::scobj::eurotherm_m2000::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - ::scobj::eurotherm_m2000::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} + ::scobj::eurotherm_m2000::sics_log 1 "::scobj::eurotherm_m2000::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::eurotherm_m2000::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of eurotherm_m2000_sct.tcl" -::scobj::eurotherm_m2000::sics_log 9 "file evaluation of eurotherm_m2000_sct.tcl" +namespace eval ::scobj::eurotherm_m2000 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_eurotherm_m2000 {name ip_address tcp_port id datype dev_id tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::eurotherm_m2000::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${dev_id}" "${tol}" +} + +clientput "file evaluation of sct_eurotherm_m2000.tcl" +::scobj::eurotherm_m2000::sics_log 9 "file evaluation of sct_eurotherm_m2000.tcl" proc ::scobj::eurotherm_m2000::read_config {} { set catch_status [ catch { set ns "::scobj::eurotherm_m2000" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -92,6 +100,12 @@ proc ::scobj::eurotherm_m2000::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -102,9 +116,9 @@ proc ::scobj::eurotherm_m2000::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "eurotherm_m2000"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -146,9 +160,9 @@ proc ::scobj::eurotherm_m2000::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_eurotherm_m2000 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_eurotherm_m2000 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/julabo_lh45_gen_sct.tcl b/site_ansto/instrument/config/environment/temperature/julabo_lh45_gen_sct.tcl index dd21a940..19074726 100644 --- a/site_ansto/instrument/config/environment/temperature/julabo_lh45_gen_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/julabo_lh45_gen_sct.tcl @@ -364,14 +364,14 @@ proc ::scobj::julabo_lh45_gen::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_port id ctrl_sensor tol } { - ::scobj::julabo_lh45_gen::sics_log 9 "::scobj::julabo_lh45_gen::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" +proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id ctrl_sensor tol } { + ::scobj::julabo_lh45_gen::sics_log 9 "::scobj::julabo_lh45_gen::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -481,7 +481,7 @@ proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/heating_power_percent 1 ${sct_controller} poll ${scobj_hpath}/lh45_state 1 ${sct_controller} poll ${scobj_hpath}/overtemp_warnlimit 1 @@ -489,7 +489,7 @@ proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_por ${sct_controller} poll ${scobj_hpath}/subtemp_warnlimit 1 ${sct_controller} write ${scobj_hpath}/setpoint } else { - ::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No poll/write for julabo_lh45_gen" + ::scobj::julabo_lh45_gen::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for julabo_lh45_gen" } hfactory ${scobj_hpath}/mode plain spy none @@ -529,13 +529,13 @@ proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/mode/on_else_off type "part" hsetprop ${scobj_hpath}/mode/on_else_off nxalias "${name}_mode_on_else_off" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/mode/ext_else_bath 1 ${sct_controller} poll ${scobj_hpath}/mode/on_else_off 1 ${sct_controller} write ${scobj_hpath}/mode/ext_else_bath ${sct_controller} write ${scobj_hpath}/mode/on_else_off } else { - ::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No poll/write for julabo_lh45_gen" + ::scobj::julabo_lh45_gen::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for julabo_lh45_gen" } hfactory ${scobj_hpath}/sensor plain spy none @@ -611,16 +611,16 @@ proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/sensor/value units "C" hsetprop ${scobj_hpath}/sensor/value nxalias "${name}_sensor_value" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/sensor/bathtemp 1 ${sct_controller} poll ${scobj_hpath}/sensor/external 1 } else { - ::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No poll/write for julabo_lh45_gen" + ::scobj::julabo_lh45_gen::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for julabo_lh45_gen" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/sensor/value ${sct_controller} } # mkDriver hook code starts @@ -635,17 +635,10 @@ proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_por handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::julabo_lh45_gen { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_julabo_lh45_gen {name ip_address tcp_port {id 1} {ctrl_sensor "bath"} {tol 5.0}} { +proc ::scobj::julabo_lh45_gen::add_driver {name device_class simulation_flag ip_address tcp_port {id 1} {ctrl_sensor "bath"} {tol 5.0}} { set catch_status [ catch { - ::scobj::julabo_lh45_gen::sics_log 9 "add_julabo_lh45_gen ${name} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::julabo_lh45_gen::sics_log 9 "::scobj::julabo_lh45_gen::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::julabo_lh45_gen::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -654,24 +647,39 @@ proc add_julabo_lh45_gen {name ip_address tcp_port {id 1} {ctrl_sensor "bath"} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} "\r" } } else { - ::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => Null sctcontroller for julabo_lh45_gen" + ::scobj::julabo_lh45_gen::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for julabo_lh45_gen" ::scobj::julabo_lh45_gen::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::julabo_lh45_gen::sics_log 1 "::scobj::julabo_lh45_gen::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" - ::scobj::julabo_lh45_gen::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol} + ::scobj::julabo_lh45_gen::sics_log 1 "::scobj::julabo_lh45_gen::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" + ::scobj::julabo_lh45_gen::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of julabo_lh45_gen_sct.tcl" -::scobj::julabo_lh45_gen::sics_log 9 "file evaluation of julabo_lh45_gen_sct.tcl" +namespace eval ::scobj::julabo_lh45_gen { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_julabo_lh45_gen {name ip_address tcp_port {id 1} {ctrl_sensor "bath"} {tol 5.0}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::julabo_lh45_gen::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${1}}" "${{ctrl_sensor}" "${"bath"}}" "${{tol}" "${5.0}}" +} + +clientput "file evaluation of sct_julabo_lh45_gen.tcl" +::scobj::julabo_lh45_gen::sics_log 9 "file evaluation of sct_julabo_lh45_gen.tcl" proc ::scobj::julabo_lh45_gen::read_config {} { set catch_status [ catch { set ns "::scobj::julabo_lh45_gen" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -679,6 +687,12 @@ proc ::scobj::julabo_lh45_gen::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -689,9 +703,9 @@ proc ::scobj::julabo_lh45_gen::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "julabo_lh45_gen"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -733,9 +747,9 @@ proc ::scobj::julabo_lh45_gen::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_julabo_lh45_gen ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_julabo_lh45_gen ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/lakeshore_218_sct.tcl b/site_ansto/instrument/config/environment/temperature/lakeshore_218_sct.tcl index f17ebe12..00d754f6 100644 --- a/site_ansto/instrument/config/environment/temperature/lakeshore_218_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/lakeshore_218_sct.tcl @@ -157,14 +157,14 @@ proc ::scobj::lakeshore_218::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::lakeshore_218::sics_log 9 "::scobj::lakeshore_218::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::lakeshore_218::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::lakeshore_218::sics_log 9 "::scobj::lakeshore_218::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -186,10 +186,10 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/krdg 1 } else { - ::scobj::lakeshore_218::sics_log 9 "[environment_simulation] => No poll/write for lakeshore_218" + ::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218" } hfactory ${scobj_hpath}/sensor plain spy none @@ -301,7 +301,7 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath}/sensor/ch8 type "part" hsetprop ${scobj_hpath}/sensor/ch8 nxalias "${name}_sensor_ch8" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/sensor/ch1 1 ${sct_controller} poll ${scobj_hpath}/sensor/ch2 1 ${sct_controller} poll ${scobj_hpath}/sensor/ch3 1 @@ -311,9 +311,9 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port ${sct_controller} poll ${scobj_hpath}/sensor/ch7 1 ${sct_controller} poll ${scobj_hpath}/sensor/ch8 1 } else { - ::scobj::lakeshore_218::sics_log 9 "[environment_simulation] => No poll/write for lakeshore_218" + ::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -321,43 +321,51 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } +proc ::scobj::lakeshore_218::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::lakeshore_218::sics_log 9 "::scobj::lakeshore_218::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for lakeshore_218" + ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::lakeshore_218::sics_log 1 "::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::lakeshore_218 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_lakeshore_218 {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::lakeshore_218::sics_log 9 "add_lakeshore_218 ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::lakeshore_218::sics_log 9 "[environment_simulation] => Null sctcontroller for lakeshore_218" - ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::lakeshore_218::sics_log 1 "::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" + ::scobj::lakeshore_218::add_driver ${name} "NXdetector" "${simulation_flag}" ${ip_address} ${tcp_port} } -clientput "file evaluation of lakeshore_218_sct.tcl" -::scobj::lakeshore_218::sics_log 9 "file evaluation of lakeshore_218_sct.tcl" +clientput "file evaluation of sct_lakeshore_218.tcl" +::scobj::lakeshore_218::sics_log 9 "file evaluation of sct_lakeshore_218.tcl" proc ::scobj::lakeshore_218::read_config {} { set catch_status [ catch { set ns "::scobj::lakeshore_218" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" + set device_class "NXdetector" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -365,6 +373,12 @@ proc ::scobj::lakeshore_218::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -375,9 +389,9 @@ proc ::scobj::lakeshore_218::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "lakeshore_218"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -404,9 +418,9 @@ proc ::scobj::lakeshore_218::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_lakeshore_218 ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_lakeshore_218 ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/temperature/lakeshore_m370_sct.tcl b/site_ansto/instrument/config/environment/temperature/lakeshore_m370_sct.tcl index 20cab233..45eaacc9 100644 --- a/site_ansto/instrument/config/environment/temperature/lakeshore_m370_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/lakeshore_m370_sct.tcl @@ -27,18 +27,19 @@ proc ::scobj::lakeshore_m370::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::lakeshore_m370::mkDriver { sct_controller name id tol} { - ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${id} ${tol}" +proc ::scobj::lakeshore_m370::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id tol } { + ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user none - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} + hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts ::scobj::lakeshore_370::mk_sct_driver $sct_controller environment $name $tol @@ -51,77 +52,82 @@ proc ::scobj::lakeshore_m370::mkDriver { sct_controller name id tol} { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::lakeshore_m370::add_driver {name device_class simulation_flag ip_address tcp_port id tol} { + set catch_status [ catch { + ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::lakeshore_m370::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for lakeshore_m370" + ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::lakeshore_m370::sics_log 1 "::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + ::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::lakeshore_m370 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } -proc add_lakeshore_m370 {name IP port id tol} { - set catch_status [ catch { - ::scobj::lakeshore_m370::sics_log 9 "add_lakeshore_m370 ${name} ${IP} ${port} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${IP}"]} { - ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" - makesctcontroller sct_${name} aqadapter ${port} - } else { - ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" - makesctcontroller sct_${name} std ${IP}:${port} - } - } else { - ::scobj::lakeshore_m370::sics_log 9 "[environment_simulation] => Null sctcontroller for lakeshore_m370" - ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::lakeshore_m370::sics_log 1 "::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${id} ${tol}" - ::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${id} ${tol} - } catch_message ] - handle_exception ${catch_status} ${catch_message} +proc add_lakeshore_m370 {name ip_address tcp_port id tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::lakeshore_m370::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${tol}" } -clientput "file evaluation of lakeshore_m370_sct.tcl" -::scobj::lakeshore_m370::sics_log 9 "file evaluation of lakeshore_m370_sct.tcl" +clientput "file evaluation of sct_lakeshore_m370.tcl" +::scobj::lakeshore_m370::sics_log 9 "file evaluation of sct_lakeshore_m370.tcl" proc ::scobj::lakeshore_m370::read_config {} { set catch_status [ catch { set ns "::scobj::lakeshore_m370" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set enabled [string tolower [dict get $v "enabled"]] + set enabled [string tolower [dict get $u "enabled"]] if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } - set name [dict get $v name] - set implementation [dict get $v "implementation"] + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } + set name [dict get $u name] + set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { continue } - set arg_list [list] - foreach arg {id} { - if {[dict exists $v $arg]} { - lappend arg_list "[dict get $v $arg]" - } else { - ${ns}::sics_log 9 "Missing configuration value $arg" - error "Missing configuration value $arg" - } - } set v [dict get $::config_dict $implementation] if { !([dict exists $v "driver"]) } { continue } if { [string equal -nocase [dict get $v "driver"] "lakeshore_m370"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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 [dict get $v ip] - set PORT [dict get $v port] + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] } } else { if { [dict exists $v "asyncprotocol"] } { @@ -135,25 +141,32 @@ proc ::scobj::lakeshore_m370::read_config {} { } } set asyncqueue ${name}_queue - set IP [dict get $v ip] - set PORT [dict get $v port] - MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT} + 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"]" } } - foreach arg {tol} { - if {[dict exists $v $arg]} { + set arg_list [list] + set missing_list [list] + foreach arg {id tol} { + if {[dict exists $u $arg]} { + lappend arg_list "[dict get $u $arg]" + } elseif {[dict exists $v $arg]} { lappend arg_list "[dict get $v $arg]" } else { ${ns}::sics_log 9 "Missing configuration value $arg" - error "Missing configuration value $arg" + lappend missing_list $arg } } + if { [llength $missing_list] > 0 } { + error "$name is missing configuration values $missing_list" + } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_lakeshore_m370 ${name} ${IP} ${PORT} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_lakeshore_m370 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/ls336_sct.tcl b/site_ansto/instrument/config/environment/temperature/ls336_sct.tcl index f7f97b40..27e7d7d8 100644 --- a/site_ansto/instrument/config/environment/temperature/ls336_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/ls336_sct.tcl @@ -27,18 +27,18 @@ proc ::scobj::ls336::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::ls336::mkDriver { sct_controller name ip_address tcp_port id datype tol1 tol2 } { - ::scobj::ls336::sics_log 9 "::scobj::ls336::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" +proc ::scobj::ls336::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype tol1 tol2 } { + ::scobj::ls336::sics_log 9 "::scobj::ls336::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::ls336::mkDriver { sct_controller name ip_address tcp_port id datyp handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::ls336 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_ls336 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { +proc ::scobj::ls336::add_driver {name device_class simulation_flag ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { set catch_status [ catch { - ::scobj::ls336::sics_log 9 "add_ls336 ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::ls336::sics_log 9 "::scobj::ls336::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::ls336::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,24 +60,39 @@ proc add_ls336 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::ls336::sics_log 9 "[environment_simulation] => Null sctcontroller for ls336" + ::scobj::ls336::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for ls336" ::scobj::ls336::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::ls336::sics_log 1 "::scobj::ls336::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" - ::scobj::ls336::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2} + ::scobj::ls336::sics_log 1 "::scobj::ls336::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" + ::scobj::ls336::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of ls336_sct.tcl" -::scobj::ls336::sics_log 9 "file evaluation of ls336_sct.tcl" +namespace eval ::scobj::ls336 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_ls336 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::ls336::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${{tol1}" "${1.0}}" "${{tol2}" "${1.0}}" +} + +clientput "file evaluation of sct_ls336.tcl" +::scobj::ls336::sics_log 9 "file evaluation of sct_ls336.tcl" proc ::scobj::ls336::read_config {} { set catch_status [ catch { set ns "::scobj::ls336" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -92,6 +100,12 @@ proc ::scobj::ls336::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -102,9 +116,9 @@ proc ::scobj::ls336::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "ls336"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -146,9 +160,9 @@ proc ::scobj::ls336::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_ls336 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_ls336 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/ls340_sct.tcl b/site_ansto/instrument/config/environment/temperature/ls340_sct.tcl index ea13283c..8d5cfafc 100644 --- a/site_ansto/instrument/config/environment/temperature/ls340_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/ls340_sct.tcl @@ -27,18 +27,18 @@ proc ::scobj::ls340::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::ls340::mkDriver { sct_controller name ip_address tcp_port id datype tol1 tol2 } { - ::scobj::ls340::sics_log 9 "::scobj::ls340::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" +proc ::scobj::ls340::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype tol1 tol2 } { + ::scobj::ls340::sics_log 9 "::scobj::ls340::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::ls340::mkDriver { sct_controller name ip_address tcp_port id datyp handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::ls340 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_ls340 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { +proc ::scobj::ls340::add_driver {name device_class simulation_flag ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { set catch_status [ catch { - ::scobj::ls340::sics_log 9 "add_ls340 ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::ls340::sics_log 9 "::scobj::ls340::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::ls340::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,24 +60,39 @@ proc add_ls340 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::ls340::sics_log 9 "[environment_simulation] => Null sctcontroller for ls340" + ::scobj::ls340::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for ls340" ::scobj::ls340::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::ls340::sics_log 1 "::scobj::ls340::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" - ::scobj::ls340::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2} + ::scobj::ls340::sics_log 1 "::scobj::ls340::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" + ::scobj::ls340::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of ls340_sct.tcl" -::scobj::ls340::sics_log 9 "file evaluation of ls340_sct.tcl" +namespace eval ::scobj::ls340 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_ls340 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::ls340::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${{tol1}" "${1.0}}" "${{tol2}" "${1.0}}" +} + +clientput "file evaluation of sct_ls340.tcl" +::scobj::ls340::sics_log 9 "file evaluation of sct_ls340.tcl" proc ::scobj::ls340::read_config {} { set catch_status [ catch { set ns "::scobj::ls340" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -92,6 +100,12 @@ proc ::scobj::ls340::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -102,9 +116,9 @@ proc ::scobj::ls340::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "ls340"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -146,9 +160,9 @@ proc ::scobj::ls340::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_ls340 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_ls340 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/mercury_base_sct.tcl b/site_ansto/instrument/config/environment/temperature/mercury_base_sct.tcl index 178d4e07..e5d1a059 100644 --- a/site_ansto/instrument/config/environment/temperature/mercury_base_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/mercury_base_sct.tcl @@ -266,14 +266,14 @@ proc ::scobj::mercury_base::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_base::mkDriver { sct_controller name ip_address tcp_port id tol } { - ::scobj::mercury_base::sics_log 9 "::scobj::mercury_base::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" +proc ::scobj::mercury_base::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id tol } { + ::scobj::mercury_base::sics_log 9 "::scobj::mercury_base::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -351,14 +351,14 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop1/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop1/setpoint nxalias "${name}_Loop1_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop1/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop1/power 5 ${sct_controller} poll ${scobj_hpath}/Loop1/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop1/setpoint } else { - ::scobj::mercury_base::sics_log 9 "[environment_simulation] => No poll/write for mercury_base" + ::scobj::mercury_base::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_base" } hfactory ${scobj_hpath}/Loop2 plain spy none @@ -434,14 +434,14 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop2/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop2/setpoint nxalias "${name}_Loop2_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop2/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop2/power 5 ${sct_controller} poll ${scobj_hpath}/Loop2/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop2/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop2/setpoint } else { - ::scobj::mercury_base::sics_log 9 "[environment_simulation] => No poll/write for mercury_base" + ::scobj::mercury_base::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_base" } hfactory ${scobj_hpath}/Loop3 plain spy none @@ -517,19 +517,19 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop3/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop3/setpoint nxalias "${name}_Loop3_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop3/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop3/power 5 ${sct_controller} poll ${scobj_hpath}/Loop3/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop3/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop3/setpoint } else { - ::scobj::mercury_base::sics_log 9 "[environment_simulation] => No poll/write for mercury_base" + ::scobj::mercury_base::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_base" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller} ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller} ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller} @@ -539,17 +539,10 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name ip_address tcp_port i handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::mercury_base { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_mercury_base {name ip_address tcp_port {id 99} {tol 1}} { +proc ::scobj::mercury_base::add_driver {name device_class simulation_flag ip_address tcp_port {id 99} {tol 1}} { set catch_status [ catch { - ::scobj::mercury_base::sics_log 9 "add_mercury_base ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::mercury_base::sics_log 9 "::scobj::mercury_base::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::mercury_base::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -558,24 +551,39 @@ proc add_mercury_base {name ip_address tcp_port {id 99} {tol 1}} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::mercury_base::sics_log 9 "[environment_simulation] => Null sctcontroller for mercury_base" + ::scobj::mercury_base::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for mercury_base" ::scobj::mercury_base::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::mercury_base::sics_log 1 "::scobj::mercury_base::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - ::scobj::mercury_base::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol} + ::scobj::mercury_base::sics_log 1 "::scobj::mercury_base::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + ::scobj::mercury_base::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of mercury_base_sct.tcl" -::scobj::mercury_base::sics_log 9 "file evaluation of mercury_base_sct.tcl" +namespace eval ::scobj::mercury_base { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_mercury_base {name ip_address tcp_port {id 99} {tol 1}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_base::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" "${{tol}" "${1}}" +} + +clientput "file evaluation of sct_mercury_base.tcl" +::scobj::mercury_base::sics_log 9 "file evaluation of sct_mercury_base.tcl" proc ::scobj::mercury_base::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_base" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -583,6 +591,12 @@ proc ::scobj::mercury_base::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -593,9 +607,9 @@ proc ::scobj::mercury_base::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_base"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -637,9 +651,9 @@ proc ::scobj::mercury_base::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_base ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_base ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/mercury_level_sct.tcl b/site_ansto/instrument/config/environment/temperature/mercury_level_sct.tcl index e46fdbba..6bd2ee09 100644 --- a/site_ansto/instrument/config/environment/temperature/mercury_level_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/mercury_level_sct.tcl @@ -137,14 +137,14 @@ proc ::scobj::mercury_level::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_level::mkDriver { sct_controller name ip_address tcp_port id } { - ::scobj::mercury_level::sics_log 9 "::scobj::mercury_level::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id}" +proc ::scobj::mercury_level::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id } { + ::scobj::mercury_level::sics_log 9 "::scobj::mercury_level::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -184,13 +184,13 @@ proc ::scobj::mercury_level::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath}/Level/Nitrogen type "part" hsetprop ${scobj_hpath}/Level/Nitrogen nxalias "${name}_Level_Nitrogen" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Level/Helium 15 ${sct_controller} poll ${scobj_hpath}/Level/Nitrogen 15 } else { - ::scobj::mercury_level::sics_log 9 "[environment_simulation] => No poll/write for mercury_level" + ::scobj::mercury_level::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_level" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -198,43 +198,51 @@ proc ::scobj::mercury_level::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } +proc ::scobj::mercury_level::add_driver {name device_class simulation_flag ip_address tcp_port {id 99}} { + set catch_status [ catch { + ::scobj::mercury_level::sics_log 9 "::scobj::mercury_level::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::mercury_level::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for mercury_level" + ::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::mercury_level::sics_log 1 "::scobj::mercury_level::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + ::scobj::mercury_level::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::mercury_level { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_mercury_level {name ip_address tcp_port {id 99}} { - set catch_status [ catch { - ::scobj::mercury_level::sics_log 9 "add_mercury_level ${name} ${ip_address} ${tcp_port} ${id}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::mercury_level::sics_log 9 "[environment_simulation] => Null sctcontroller for mercury_level" - ::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::mercury_level::sics_log 1 "::scobj::mercury_level::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id}" - ::scobj::mercury_level::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_level::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" } -clientput "file evaluation of mercury_level_sct.tcl" -::scobj::mercury_level::sics_log 9 "file evaluation of mercury_level_sct.tcl" +clientput "file evaluation of sct_mercury_level.tcl" +::scobj::mercury_level::sics_log 9 "file evaluation of sct_mercury_level.tcl" proc ::scobj::mercury_level::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_level" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -242,6 +250,12 @@ proc ::scobj::mercury_level::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -252,9 +266,9 @@ proc ::scobj::mercury_level::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_level"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -296,9 +310,9 @@ proc ::scobj::mercury_level::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_level ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_level ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/mercury_pres_sct.tcl b/site_ansto/instrument/config/environment/temperature/mercury_pres_sct.tcl index d6b86b7a..0dfcdfa6 100644 --- a/site_ansto/instrument/config/environment/temperature/mercury_pres_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/mercury_pres_sct.tcl @@ -272,14 +272,14 @@ proc ::scobj::mercury_pres::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_pres::mkDriver { sct_controller name ip_address tcp_port id tol } { - ::scobj::mercury_pres::sics_log 9 "::scobj::mercury_pres::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" +proc ::scobj::mercury_pres::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id tol } { + ::scobj::mercury_pres::sics_log 9 "::scobj::mercury_pres::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -346,18 +346,18 @@ proc ::scobj::mercury_pres::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop8/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop8/setpoint nxalias "${name}_Loop8_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop8/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop8/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop8/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop8/setpoint } else { - ::scobj::mercury_pres::sics_log 9 "[environment_simulation] => No poll/write for mercury_pres" + ::scobj::mercury_pres::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_pres" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Loop8_setpoint ${scobj_hpath}/Loop8/setpoint ${scobj_hpath}/Loop8/sensor ${sct_controller} } # mkDriver hook code goes here @@ -365,43 +365,51 @@ proc ::scobj::mercury_pres::mkDriver { sct_controller name ip_address tcp_port i handle_exception ${catch_status} ${catch_message} } +proc ::scobj::mercury_pres::add_driver {name device_class simulation_flag ip_address tcp_port {id 99} {tol 1}} { + set catch_status [ catch { + ::scobj::mercury_pres::sics_log 9 "::scobj::mercury_pres::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::mercury_pres::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for mercury_pres" + ::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::mercury_pres::sics_log 1 "::scobj::mercury_pres::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + ::scobj::mercury_pres::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::mercury_pres { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_mercury_pres {name ip_address tcp_port {id 99} {tol 1}} { - set catch_status [ catch { - ::scobj::mercury_pres::sics_log 9 "add_mercury_pres ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::mercury_pres::sics_log 9 "[environment_simulation] => Null sctcontroller for mercury_pres" - ::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::mercury_pres::sics_log 1 "::scobj::mercury_pres::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - ::scobj::mercury_pres::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_pres::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" "${{tol}" "${1}}" } -clientput "file evaluation of mercury_pres_sct.tcl" -::scobj::mercury_pres::sics_log 9 "file evaluation of mercury_pres_sct.tcl" +clientput "file evaluation of sct_mercury_pres.tcl" +::scobj::mercury_pres::sics_log 9 "file evaluation of sct_mercury_pres.tcl" proc ::scobj::mercury_pres::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_pres" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -409,6 +417,12 @@ proc ::scobj::mercury_pres::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -419,9 +433,9 @@ proc ::scobj::mercury_pres::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_pres"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -463,9 +477,9 @@ proc ::scobj::mercury_pres::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_pres ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_pres ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/mercury_scpi_sct.tcl b/site_ansto/instrument/config/environment/temperature/mercury_scpi_sct.tcl index 04f6e2f4..a066b76f 100644 --- a/site_ansto/instrument/config/environment/temperature/mercury_scpi_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/mercury_scpi_sct.tcl @@ -300,14 +300,14 @@ proc ::scobj::mercury_scpi::setValve {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port id permlink tol valve_tol } { - ::scobj::mercury_scpi::sics_log 9 "::scobj::mercury_scpi::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" +proc ::scobj::mercury_scpi::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id permlink tol valve_tol } { + ::scobj::mercury_scpi::sics_log 9 "::scobj::mercury_scpi::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -347,11 +347,11 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Level/Nitrogen type "part" hsetprop ${scobj_hpath}/Level/Nitrogen nxalias "${name}_Level_Nitrogen" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Level/Helium 15 ${sct_controller} poll ${scobj_hpath}/Level/Nitrogen 15 } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } hfactory ${scobj_hpath}/Loop1 plain spy none @@ -427,14 +427,14 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop1/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop1/setpoint nxalias "${name}_Loop1_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop1/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop1/power 5 ${sct_controller} poll ${scobj_hpath}/Loop1/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop1/setpoint } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } hfactory ${scobj_hpath}/Loop2 plain spy none @@ -510,14 +510,14 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop2/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop2/setpoint nxalias "${name}_Loop2_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop2/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop2/power 5 ${sct_controller} poll ${scobj_hpath}/Loop2/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop2/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop2/setpoint } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } hfactory ${scobj_hpath}/Loop3 plain spy none @@ -593,14 +593,14 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop3/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop3/setpoint nxalias "${name}_Loop3_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop3/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop3/power 5 ${sct_controller} poll ${scobj_hpath}/Loop3/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop3/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop3/setpoint } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } hfactory ${scobj_hpath}/Loop4 plain spy none @@ -676,14 +676,14 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop4/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop4/setpoint nxalias "${name}_Loop4_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop4/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop4/power 5 ${sct_controller} poll ${scobj_hpath}/Loop4/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop4/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop4/setpoint } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } hfactory ${scobj_hpath}/Valve plain spy none @@ -731,16 +731,16 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Valve/setpoint type "drivable" hsetprop ${scobj_hpath}/Valve/setpoint nxalias "${name}_Valve_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Valve/sensor 5 ${sct_controller} write ${scobj_hpath}/Valve/setpoint } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller} ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller} ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller} @@ -752,17 +752,10 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::mercury_scpi { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_mercury_scpi {name ip_address tcp_port {id 99} {permlink LT} {tol 1} {valve_tol 2}} { +proc ::scobj::mercury_scpi::add_driver {name device_class simulation_flag ip_address tcp_port {id 99} {permlink LT} {tol 1} {valve_tol 2}} { set catch_status [ catch { - ::scobj::mercury_scpi::sics_log 9 "add_mercury_scpi ${name} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::mercury_scpi::sics_log 9 "::scobj::mercury_scpi::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::mercury_scpi::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -771,24 +764,39 @@ proc add_mercury_scpi {name ip_address tcp_port {id 99} {permlink LT} {tol 1} {v makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => Null sctcontroller for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for mercury_scpi" ::scobj::mercury_scpi::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::mercury_scpi::sics_log 1 "::scobj::mercury_scpi::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" - ::scobj::mercury_scpi::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol} + ::scobj::mercury_scpi::sics_log 1 "::scobj::mercury_scpi::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" + ::scobj::mercury_scpi::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of mercury_scpi_sct.tcl" -::scobj::mercury_scpi::sics_log 9 "file evaluation of mercury_scpi_sct.tcl" +namespace eval ::scobj::mercury_scpi { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_mercury_scpi {name ip_address tcp_port {id 99} {permlink LT} {tol 1} {valve_tol 2}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_scpi::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" "${{permlink}" "${LT}}" "${{tol}" "${1}}" "${{valve_tol}" "${2}}" +} + +clientput "file evaluation of sct_mercury_scpi.tcl" +::scobj::mercury_scpi::sics_log 9 "file evaluation of sct_mercury_scpi.tcl" proc ::scobj::mercury_scpi::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_scpi" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -796,6 +804,12 @@ proc ::scobj::mercury_scpi::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -806,9 +820,9 @@ proc ::scobj::mercury_scpi::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_scpi"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -850,9 +864,9 @@ proc ::scobj::mercury_scpi::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_scpi ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_scpi ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/mercury_temp_sct.tcl b/site_ansto/instrument/config/environment/temperature/mercury_temp_sct.tcl index d8b2e3e4..f870fa48 100644 --- a/site_ansto/instrument/config/environment/temperature/mercury_temp_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/mercury_temp_sct.tcl @@ -266,14 +266,14 @@ proc ::scobj::mercury_temp::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_temp::mkDriver { sct_controller name ip_address tcp_port id tol } { - ::scobj::mercury_temp::sics_log 9 "::scobj::mercury_temp::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" +proc ::scobj::mercury_temp::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id tol } { + ::scobj::mercury_temp::sics_log 9 "::scobj::mercury_temp::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -351,19 +351,19 @@ proc ::scobj::mercury_temp::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop4/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop4/setpoint nxalias "${name}_Loop4_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop4/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop4/power 5 ${sct_controller} poll ${scobj_hpath}/Loop4/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop4/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop4/setpoint } else { - ::scobj::mercury_temp::sics_log 9 "[environment_simulation] => No poll/write for mercury_temp" + ::scobj::mercury_temp::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_temp" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller} } # mkDriver hook code goes here @@ -371,43 +371,51 @@ proc ::scobj::mercury_temp::mkDriver { sct_controller name ip_address tcp_port i handle_exception ${catch_status} ${catch_message} } +proc ::scobj::mercury_temp::add_driver {name device_class simulation_flag ip_address tcp_port {id 99} {tol 1}} { + set catch_status [ catch { + ::scobj::mercury_temp::sics_log 9 "::scobj::mercury_temp::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::mercury_temp::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for mercury_temp" + ::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::mercury_temp::sics_log 1 "::scobj::mercury_temp::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + ::scobj::mercury_temp::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::mercury_temp { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_mercury_temp {name ip_address tcp_port {id 99} {tol 1}} { - set catch_status [ catch { - ::scobj::mercury_temp::sics_log 9 "add_mercury_temp ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::mercury_temp::sics_log 9 "[environment_simulation] => Null sctcontroller for mercury_temp" - ::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::mercury_temp::sics_log 1 "::scobj::mercury_temp::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - ::scobj::mercury_temp::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_temp::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" "${{tol}" "${1}}" } -clientput "file evaluation of mercury_temp_sct.tcl" -::scobj::mercury_temp::sics_log 9 "file evaluation of mercury_temp_sct.tcl" +clientput "file evaluation of sct_mercury_temp.tcl" +::scobj::mercury_temp::sics_log 9 "file evaluation of sct_mercury_temp.tcl" proc ::scobj::mercury_temp::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_temp" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -415,6 +423,12 @@ proc ::scobj::mercury_temp::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -425,9 +439,9 @@ proc ::scobj::mercury_temp::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_temp"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -469,9 +483,9 @@ proc ::scobj::mercury_temp::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_temp ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_temp ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/mercury_valve_sct.tcl b/site_ansto/instrument/config/environment/temperature/mercury_valve_sct.tcl index 0c3bf363..fd6c0057 100644 --- a/site_ansto/instrument/config/environment/temperature/mercury_valve_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/mercury_valve_sct.tcl @@ -244,14 +244,14 @@ proc ::scobj::mercury_valve::setValve {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_valve::mkDriver { sct_controller name ip_address tcp_port id valve_tol } { - ::scobj::mercury_valve::sics_log 9 "::scobj::mercury_valve::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${valve_tol}" +proc ::scobj::mercury_valve::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id valve_tol } { + ::scobj::mercury_valve::sics_log 9 "::scobj::mercury_valve::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${valve_tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -301,16 +301,16 @@ proc ::scobj::mercury_valve::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath}/Valve/setpoint type "drivable" hsetprop ${scobj_hpath}/Valve/setpoint nxalias "${name}_Valve_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Valve/sensor 5 ${sct_controller} write ${scobj_hpath}/Valve/setpoint } else { - ::scobj::mercury_valve::sics_log 9 "[environment_simulation] => No poll/write for mercury_valve" + ::scobj::mercury_valve::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_valve" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Valve_setpoint ${scobj_hpath}/Valve/setpoint ${scobj_hpath}/Valve/sensor ${sct_controller} } # mkDriver hook code goes here @@ -318,43 +318,51 @@ proc ::scobj::mercury_valve::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } +proc ::scobj::mercury_valve::add_driver {name device_class simulation_flag ip_address tcp_port {id 99} {valve_tol 2}} { + set catch_status [ catch { + ::scobj::mercury_valve::sics_log 9 "::scobj::mercury_valve::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${valve_tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::mercury_valve::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for mercury_valve" + ::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::mercury_valve::sics_log 1 "::scobj::mercury_valve::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${valve_tol}" + ::scobj::mercury_valve::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${valve_tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::mercury_valve { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_mercury_valve {name ip_address tcp_port {id 99} {valve_tol 2}} { - set catch_status [ catch { - ::scobj::mercury_valve::sics_log 9 "add_mercury_valve ${name} ${ip_address} ${tcp_port} ${id} ${valve_tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::mercury_valve::sics_log 9 "[environment_simulation] => Null sctcontroller for mercury_valve" - ::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::mercury_valve::sics_log 1 "::scobj::mercury_valve::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${valve_tol}" - ::scobj::mercury_valve::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${valve_tol} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_valve::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" "${{valve_tol}" "${2}}" } -clientput "file evaluation of mercury_valve_sct.tcl" -::scobj::mercury_valve::sics_log 9 "file evaluation of mercury_valve_sct.tcl" +clientput "file evaluation of sct_mercury_valve.tcl" +::scobj::mercury_valve::sics_log 9 "file evaluation of sct_mercury_valve.tcl" proc ::scobj::mercury_valve::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_valve" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -362,6 +370,12 @@ proc ::scobj::mercury_valve::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -372,9 +386,9 @@ proc ::scobj::mercury_valve::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_valve"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -416,9 +430,9 @@ proc ::scobj::mercury_valve::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_valve ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_valve ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/nprvasm2_sct.tcl b/site_ansto/instrument/config/environment/temperature/nprvasm2_sct.tcl index 2e67fff6..411f00ef 100644 --- a/site_ansto/instrument/config/environment/temperature/nprvasm2_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/nprvasm2_sct.tcl @@ -27,18 +27,18 @@ proc ::scobj::nprvasm2::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::nprvasm2::mkDriver { sct_controller name ip_address tcp_port tol } { - ::scobj::nprvasm2::sics_log 9 "::scobj::nprvasm2::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${tol}" +proc ::scobj::nprvasm2::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port tol } { + ::scobj::nprvasm2::sics_log 9 "::scobj::nprvasm2::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::nprvasm2::mkDriver { sct_controller name ip_address tcp_port tol } handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::nprvasm2 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_nprvasm2 {name ip_address tcp_port {tol 1.0}} { +proc ::scobj::nprvasm2::add_driver {name device_class simulation_flag ip_address tcp_port {tol 1.0}} { set catch_status [ catch { - ::scobj::nprvasm2::sics_log 9 "add_nprvasm2 ${name} ${ip_address} ${tcp_port} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::nprvasm2::sics_log 9 "::scobj::nprvasm2::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::nprvasm2::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,24 +60,39 @@ proc add_nprvasm2 {name ip_address tcp_port {tol 1.0}} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::nprvasm2::sics_log 9 "[environment_simulation] => Null sctcontroller for nprvasm2" + ::scobj::nprvasm2::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for nprvasm2" ::scobj::nprvasm2::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::nprvasm2::sics_log 1 "::scobj::nprvasm2::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${tol}" - ::scobj::nprvasm2::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${tol} + ::scobj::nprvasm2::sics_log 1 "::scobj::nprvasm2::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${tol}" + ::scobj::nprvasm2::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of nprvasm2_sct.tcl" -::scobj::nprvasm2::sics_log 9 "file evaluation of nprvasm2_sct.tcl" +namespace eval ::scobj::nprvasm2 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_nprvasm2 {name ip_address tcp_port {tol 1.0}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::nprvasm2::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{tol}" "${1.0}}" +} + +clientput "file evaluation of sct_nprvasm2.tcl" +::scobj::nprvasm2::sics_log 9 "file evaluation of sct_nprvasm2.tcl" proc ::scobj::nprvasm2::read_config {} { set catch_status [ catch { set ns "::scobj::nprvasm2" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -92,6 +100,12 @@ proc ::scobj::nprvasm2::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -102,9 +116,9 @@ proc ::scobj::nprvasm2::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "nprvasm2"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -146,9 +160,9 @@ proc ::scobj::nprvasm2::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_nprvasm2 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_nprvasm2 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/pfeiffer_hg_sct.tcl b/site_ansto/instrument/config/environment/temperature/pfeiffer_hg_sct.tcl index a59d6768..4807e921 100644 --- a/site_ansto/instrument/config/environment/temperature/pfeiffer_hg_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/pfeiffer_hg_sct.tcl @@ -370,8 +370,8 @@ proc ::scobj::pfeiffer_hg::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::pfeiffer_hg::sics_log 9 "::scobj::pfeiffer_hg::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::pfeiffer_hg::sics_log 9 "::scobj::pfeiffer_hg::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { @@ -379,7 +379,7 @@ proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name ip_address tcp_port } MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -453,16 +453,16 @@ proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name ip_address tcp_port } hsetprop ${scobj_hpath}/pressure/setpoint type "drivable" hsetprop ${scobj_hpath}/pressure/setpoint nxalias "${name}_pressure_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/pressure/sensor 1 ${sct_controller} write ${scobj_hpath}/pressure/setpoint } else { - ::scobj::pfeiffer_hg::sics_log 9 "[environment_simulation] => No poll/write for pfeiffer_hg" + ::scobj::pfeiffer_hg::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for pfeiffer_hg" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_pressure_setpoint ${scobj_hpath}/pressure/setpoint ${scobj_hpath}/pressure/sensor ${sct_controller} } # mkDriver hook code starts @@ -473,17 +473,10 @@ proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name ip_address tcp_port } handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::pfeiffer_hg { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_pfeiffer_hg {name ip_address tcp_port} { +proc ::scobj::pfeiffer_hg::add_driver {name device_class simulation_flag ip_address tcp_port} { set catch_status [ catch { - ::scobj::pfeiffer_hg::sics_log 9 "add_pfeiffer_hg ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::pfeiffer_hg::sics_log 9 "::scobj::pfeiffer_hg::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::pfeiffer_hg::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -492,24 +485,39 @@ proc add_pfeiffer_hg {name ip_address tcp_port} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::pfeiffer_hg::sics_log 9 "[environment_simulation] => Null sctcontroller for pfeiffer_hg" + ::scobj::pfeiffer_hg::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for pfeiffer_hg" ::scobj::pfeiffer_hg::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::pfeiffer_hg::sics_log 1 "::scobj::pfeiffer_hg::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::pfeiffer_hg::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} + ::scobj::pfeiffer_hg::sics_log 1 "::scobj::pfeiffer_hg::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::pfeiffer_hg::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of pfeiffer_hg_sct.tcl" -::scobj::pfeiffer_hg::sics_log 9 "file evaluation of pfeiffer_hg_sct.tcl" +namespace eval ::scobj::pfeiffer_hg { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_pfeiffer_hg {name ip_address tcp_port} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::pfeiffer_hg::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} +} + +clientput "file evaluation of sct_pfeiffer_hg.tcl" +::scobj::pfeiffer_hg::sics_log 9 "file evaluation of sct_pfeiffer_hg.tcl" proc ::scobj::pfeiffer_hg::read_config {} { set catch_status [ catch { set ns "::scobj::pfeiffer_hg" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -517,6 +525,12 @@ proc ::scobj::pfeiffer_hg::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -527,9 +541,9 @@ proc ::scobj::pfeiffer_hg::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "pfeiffer_hg"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -556,9 +570,9 @@ proc ::scobj::pfeiffer_hg::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_pfeiffer_hg ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_pfeiffer_hg ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/temperature/watlow_mpm_sct.tcl b/site_ansto/instrument/config/environment/temperature/watlow_mpm_sct.tcl index 9c525646..48cc987b 100644 --- a/site_ansto/instrument/config/environment/temperature/watlow_mpm_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/watlow_mpm_sct.tcl @@ -27,18 +27,18 @@ proc ::scobj::watlow_mpm::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::watlow_mpm::mkDriver { sct_controller name ip_address tcp_port id datype dev_id tol } { - ::scobj::watlow_mpm::sics_log 9 "::scobj::watlow_mpm::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" +proc ::scobj::watlow_mpm::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id tol } { + ::scobj::watlow_mpm::sics_log 9 "::scobj::watlow_mpm::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::watlow_mpm::mkDriver { sct_controller name ip_address tcp_port id handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::watlow_mpm { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_watlow_mpm {name ip_address tcp_port id datype dev_id tol} { +proc ::scobj::watlow_mpm::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id tol} { set catch_status [ catch { - ::scobj::watlow_mpm::sics_log 9 "add_watlow_mpm ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::watlow_mpm::sics_log 9 "::scobj::watlow_mpm::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::watlow_mpm::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,24 +60,39 @@ proc add_watlow_mpm {name ip_address tcp_port id datype dev_id tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::watlow_mpm::sics_log 9 "[environment_simulation] => Null sctcontroller for watlow_mpm" + ::scobj::watlow_mpm::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for watlow_mpm" ::scobj::watlow_mpm::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::watlow_mpm::sics_log 1 "::scobj::watlow_mpm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - ::scobj::watlow_mpm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} + ::scobj::watlow_mpm::sics_log 1 "::scobj::watlow_mpm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::watlow_mpm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of watlow_mpm_sct.tcl" -::scobj::watlow_mpm::sics_log 9 "file evaluation of watlow_mpm_sct.tcl" +namespace eval ::scobj::watlow_mpm { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_watlow_mpm {name ip_address tcp_port id datype dev_id tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::watlow_mpm::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${dev_id}" "${tol}" +} + +clientput "file evaluation of sct_watlow_mpm.tcl" +::scobj::watlow_mpm::sics_log 9 "file evaluation of sct_watlow_mpm.tcl" proc ::scobj::watlow_mpm::read_config {} { set catch_status [ catch { set ns "::scobj::watlow_mpm" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -92,6 +100,12 @@ proc ::scobj::watlow_mpm::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -102,9 +116,9 @@ proc ::scobj::watlow_mpm::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "watlow_mpm"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -146,9 +160,9 @@ proc ::scobj::watlow_mpm::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_watlow_mpm ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_watlow_mpm ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/watlow_mrm_sct.tcl b/site_ansto/instrument/config/environment/temperature/watlow_mrm_sct.tcl index f29f87db..577fda50 100644 --- a/site_ansto/instrument/config/environment/temperature/watlow_mrm_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/watlow_mrm_sct.tcl @@ -27,18 +27,18 @@ proc ::scobj::watlow_mrm::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::watlow_mrm::mkDriver { sct_controller name ip_address tcp_port id datype dev_id tol } { - ::scobj::watlow_mrm::sics_log 9 "::scobj::watlow_mrm::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" +proc ::scobj::watlow_mrm::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id tol } { + ::scobj::watlow_mrm::sics_log 9 "::scobj::watlow_mrm::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::watlow_mrm::mkDriver { sct_controller name ip_address tcp_port id handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::watlow_mrm { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_watlow_mrm {name ip_address tcp_port id datype dev_id tol} { +proc ::scobj::watlow_mrm::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id tol} { set catch_status [ catch { - ::scobj::watlow_mrm::sics_log 9 "add_watlow_mrm ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::watlow_mrm::sics_log 9 "::scobj::watlow_mrm::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::watlow_mrm::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,24 +60,39 @@ proc add_watlow_mrm {name ip_address tcp_port id datype dev_id tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::watlow_mrm::sics_log 9 "[environment_simulation] => Null sctcontroller for watlow_mrm" + ::scobj::watlow_mrm::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for watlow_mrm" ::scobj::watlow_mrm::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::watlow_mrm::sics_log 1 "::scobj::watlow_mrm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - ::scobj::watlow_mrm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} + ::scobj::watlow_mrm::sics_log 1 "::scobj::watlow_mrm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::watlow_mrm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of watlow_mrm_sct.tcl" -::scobj::watlow_mrm::sics_log 9 "file evaluation of watlow_mrm_sct.tcl" +namespace eval ::scobj::watlow_mrm { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_watlow_mrm {name ip_address tcp_port id datype dev_id tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::watlow_mrm::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${dev_id}" "${tol}" +} + +clientput "file evaluation of sct_watlow_mrm.tcl" +::scobj::watlow_mrm::sics_log 9 "file evaluation of sct_watlow_mrm.tcl" proc ::scobj::watlow_mrm::read_config {} { set catch_status [ catch { set ns "::scobj::watlow_mrm" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -92,6 +100,12 @@ proc ::scobj::watlow_mrm::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -102,9 +116,9 @@ proc ::scobj::watlow_mrm::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "watlow_mrm"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -146,9 +160,9 @@ proc ::scobj::watlow_mrm::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_watlow_mrm ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_watlow_mrm ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/watlow_mst4_sct.tcl b/site_ansto/instrument/config/environment/temperature/watlow_mst4_sct.tcl index e3584526..7d0f2557 100644 --- a/site_ansto/instrument/config/environment/temperature/watlow_mst4_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/watlow_mst4_sct.tcl @@ -27,18 +27,18 @@ proc ::scobj::watlow_mst4::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::watlow_mst4::mkDriver { sct_controller name ip_address tcp_port id datype dev_id tol } { - ::scobj::watlow_mst4::sics_log 9 "::scobj::watlow_mst4::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" +proc ::scobj::watlow_mst4::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id tol } { + ::scobj::watlow_mst4::sics_log 9 "::scobj::watlow_mst4::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::watlow_mst4::mkDriver { sct_controller name ip_address tcp_port id handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::watlow_mst4 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_watlow_mst4 {name ip_address tcp_port id datype dev_id tol} { +proc ::scobj::watlow_mst4::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id tol} { set catch_status [ catch { - ::scobj::watlow_mst4::sics_log 9 "add_watlow_mst4 ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::watlow_mst4::sics_log 9 "::scobj::watlow_mst4::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::watlow_mst4::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,24 +60,39 @@ proc add_watlow_mst4 {name ip_address tcp_port id datype dev_id tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::watlow_mst4::sics_log 9 "[environment_simulation] => Null sctcontroller for watlow_mst4" + ::scobj::watlow_mst4::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for watlow_mst4" ::scobj::watlow_mst4::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } - ::scobj::watlow_mst4::sics_log 1 "::scobj::watlow_mst4::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - ::scobj::watlow_mst4::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} + ::scobj::watlow_mst4::sics_log 1 "::scobj::watlow_mst4::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::watlow_mst4::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of watlow_mst4_sct.tcl" -::scobj::watlow_mst4::sics_log 9 "file evaluation of watlow_mst4_sct.tcl" +namespace eval ::scobj::watlow_mst4 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_watlow_mst4 {name ip_address tcp_port id datype dev_id tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::watlow_mst4::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${dev_id}" "${tol}" +} + +clientput "file evaluation of sct_watlow_mst4.tcl" +::scobj::watlow_mst4::sics_log 9 "file evaluation of sct_watlow_mst4.tcl" proc ::scobj::watlow_mst4::read_config {} { set catch_status [ catch { set ns "::scobj::watlow_mst4" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -92,6 +100,12 @@ proc ::scobj::watlow_mst4::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -102,9 +116,9 @@ proc ::scobj::watlow_mst4::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "watlow_mst4"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -146,9 +160,9 @@ proc ::scobj::watlow_mst4::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_watlow_mst4 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_watlow_mst4 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/west4100_sct.tcl b/site_ansto/instrument/config/environment/temperature/west4100_sct.tcl index 05ea5628..d72629bc 100644 --- a/site_ansto/instrument/config/environment/temperature/west4100_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/west4100_sct.tcl @@ -62,8 +62,8 @@ proc add_west4100 {name ip_address tcp_port dev_id} { ::scobj::west4100::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${dev_id}" } -clientput "file evaluation of west4100_sct.tcl" -::scobj::west4100::sics_log 9 "file evaluation of west4100_sct.tcl" +clientput "file evaluation of sct_west4100.tcl" +::scobj::west4100::sics_log 9 "file evaluation of sct_west4100.tcl" proc ::scobj::west4100::read_config {} { set catch_status [ catch { diff --git a/site_ansto/instrument/config/environment/temperature/west_6100_sct.tcl b/site_ansto/instrument/config/environment/temperature/west_6100_sct.tcl index ccf8c5f5..ddf8561d 100644 --- a/site_ansto/instrument/config/environment/temperature/west_6100_sct.tcl +++ b/site_ansto/instrument/config/environment/temperature/west_6100_sct.tcl @@ -126,7 +126,10 @@ proc ::scobj::west_6100::rdDecimal {tc_root} { error "[sct geterror]" } # rdDecimal hook code starts - set data [expr {0.10 * ${data}}] + set decimal [hval ${tc_root}/aux/decimal] + if { ${decimal} > 0 } { + set data [expr {pow(10, -${decimal}) * ${data}}] + } # rdDecimal hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" @@ -203,7 +206,12 @@ proc ::scobj::west_6100::wrDecimal {tc_root nextState cmd_str} { set par [sct target] set cmd "${cmd_str}${par}" # wrDecimal hook code starts - set par [expr {round(10.0 * [sct target])}] + set decimal [hval ${tc_root}/aux/decimal] + set par [sct target] + if { ${decimal} > 0 } { + set par [expr {pow(10, ${decimal}) * ${par}}] + } + set par [expr {round(${par})}] set cmd "1:16:${cmd_str}:1:U16:${par}" # wrDecimal hook code ends if { [hpropexists [sct] geterror] } { @@ -254,14 +262,14 @@ proc ::scobj::west_6100::wrInteger {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_id } { - ::scobj::west_6100::sics_log 9 "::scobj::west_6100::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${dev_id}" +proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port dev_id } { + ::scobj::west_6100::sics_log 9 "::scobj::west_6100::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -392,7 +400,7 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_ hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + 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 @@ -408,7 +416,7 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_ ${sct_controller} write ${scobj_hpath}/setpoint ${sct_controller} write ${scobj_hpath}/w_sp } else { - ::scobj::west_6100::sics_log 9 "[environment_simulation] => No poll/write for west_6100" + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" } hfactory ${scobj_hpath}/aux plain spy none @@ -424,6 +432,7 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_ hsetprop ${scobj_hpath}/aux/decimal mutable false hsetprop ${scobj_hpath}/aux/decimal nxsave false hsetprop ${scobj_hpath}/aux/decimal oldval 0 + hset ${scobj_hpath}/aux/decimal 0 hsetprop ${scobj_hpath}/aux/decimal sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/aux/decimal type "part" hsetprop ${scobj_hpath}/aux/decimal nxalias "${name}_aux_decimal" @@ -452,14 +461,14 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_ hsetprop ${scobj_hpath}/aux/model type "part" hsetprop ${scobj_hpath}/aux/model nxalias "${name}_aux_model" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + 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 } else { - ::scobj::west_6100::sics_log 9 "[environment_simulation] => No poll/write for west_6100" + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -467,43 +476,51 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_ handle_exception ${catch_status} ${catch_message} } +proc ::scobj::west_6100::add_driver {name device_class simulation_flag ip_address tcp_port dev_id} { + set catch_status [ catch { + ::scobj::west_6100::sics_log 9 "::scobj::west_6100::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port} + } + } else { + ::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} ${dev_id}" + ::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::west_6100 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_west_6100 {name ip_address tcp_port dev_id} { - set catch_status [ catch { - ::scobj::west_6100::sics_log 9 "add_west_6100 ${name} ${ip_address} ${tcp_port} ${dev_id}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port} - } - } else { - ::scobj::west_6100::sics_log 9 "[environment_simulation] => 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} ${ip_address} ${tcp_port} ${dev_id}" - ::scobj::west_6100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::west_6100::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${dev_id}" } -clientput "file evaluation of west_6100_sct.tcl" -::scobj::west_6100::sics_log 9 "file evaluation of west_6100_sct.tcl" +clientput "file evaluation of sct_west_6100.tcl" +::scobj::west_6100::sics_log 9 "file evaluation of sct_west_6100.tcl" proc ::scobj::west_6100::read_config {} { set catch_status [ catch { set ns "::scobj::west_6100" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -511,6 +528,12 @@ proc ::scobj::west_6100::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -521,9 +544,9 @@ proc ::scobj::west_6100::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "west_6100"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${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"] } { @@ -565,9 +588,9 @@ proc ::scobj::west_6100::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_west_6100 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_west_6100 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/source/reactor_status_sct.tcl b/site_ansto/instrument/config/source/reactor_status_sct.tcl index 09ce38c8..acb06bab 100644 --- a/site_ansto/instrument/config/source/reactor_status_sct.tcl +++ b/site_ansto/instrument/config/source/reactor_status_sct.tcl @@ -216,14 +216,14 @@ proc ::scobj::reactor_status::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::reactor_status::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::reactor_status::sics_log 9 "::scobj::reactor_status::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::reactor_status::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::reactor_status::sics_log 9 "::scobj::reactor_status::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass NXsource + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -300,12 +300,12 @@ proc ::scobj::reactor_status::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [opal_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/status 30 } else { - ::scobj::reactor_status::sics_log 9 "[opal_simulation] => No poll/write for reactor_status" + ::scobj::reactor_status::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for reactor_status" } - hsetprop ${scobj_hpath} klass NXsource + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -314,43 +314,51 @@ proc ::scobj::reactor_status::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } +proc ::scobj::reactor_status::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::reactor_status::sics_log 9 "::scobj::reactor_status::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::reactor_status::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::reactor_status::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::reactor_status::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for reactor_status" + ::scobj::reactor_status::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" + makesctcontroller sct_${name} aqadapter NULL + } + ::scobj::reactor_status::sics_log 1 "::scobj::reactor_status::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::reactor_status::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::reactor_status { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_reactor_status {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::reactor_status::sics_log 9 "add_reactor_status ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [opal_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::reactor_status::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::reactor_status::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::reactor_status::sics_log 9 "[opal_simulation] => Null sctcontroller for reactor_status" - ::scobj::reactor_status::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" - makesctcontroller sct_${name} aqadapter NULL - } - ::scobj::reactor_status::sics_log 1 "::scobj::reactor_status::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::reactor_status::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [opal_simulation]]]" + ::scobj::reactor_status::add_driver ${name} "NXsource" "${simulation_flag}" ${ip_address} ${tcp_port} } -clientput "file evaluation of reactor_status_sct.tcl" -::scobj::reactor_status::sics_log 9 "file evaluation of reactor_status_sct.tcl" +clientput "file evaluation of sct_reactor_status.tcl" +::scobj::reactor_status::sics_log 9 "file evaluation of sct_reactor_status.tcl" proc ::scobj::reactor_status::read_config {} { set catch_status [ catch { set ns "::scobj::reactor_status" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [opal_simulation]]]" + set device_class "NXsource" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -358,6 +366,12 @@ proc ::scobj::reactor_status::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -368,9 +382,9 @@ proc ::scobj::reactor_status::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "reactor_status"] } { - if { ![string equal -nocase [SplitReply [opal_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[opal_simulation] => using null asyncqueue" + ${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"] } { @@ -397,9 +411,9 @@ proc ::scobj::reactor_status::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_reactor_status ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_reactor_status ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } }