diff --git a/site_ansto/instrument/reflectometer/config/chopper/chopper.tcl b/site_ansto/instrument/reflectometer/config/chopper/chopper.tcl index 88c188ea..b05ee405 100644 --- a/site_ansto/instrument/reflectometer/config/chopper/chopper.tcl +++ b/site_ansto/instrument/reflectometer/config/chopper/chopper.tcl @@ -1,64 +1,63 @@ set sim_mode [SplitReply [chopper_simulation]] set CH1_MAXSPEED 1800 + +namespace eval ::chopper {} if {$sim_mode == "true"} { MakeChopper chopperController sim ChopperAdapter chspeed chopperController speed 0 $CH1_MAXSPEED ChopperAdapter ch2phase chopperController phase 0 180 ChopperAdapter ch3phase chopperController phase 0 180 ChopperAdapter ch4phase chopperController phase 0 180 - namespace eval ::chopper { - proc ready? {} {} - proc get_frequency {} {variable frequency; return $frequency} - proc set_frequency {freq} {variable frequency; set frequency $freq} - set_frequency 0 - } + proc ::chopper::ready? {} {} + proc ::chopper::get_frequency {} {variable frequency; return $frequency} + proc ::chopper::set_frequency {freq} {variable frequency; set frequency $freq} + ::chopper::set_frequency 0 + publish ::chopper::ready? user publish ::chopper::get_frequency user publish ::chopper::set_frequency user } else { # Chopper NCS013 communications set chopper_controller(host) 137.157.202.130 - set chopper_controller(port) 10000 - set chopper_controller(user) NCS - set chopper_controller(password) NCS013 + set chopper_controller(port) 10000 + set chopper_controller(user) NCS + set chopper_controller(password) NCS013 # CHOPPER - MakeChopper chopperController tcpdocho [params \ - host $chopper_controller(host) \ - port $chopper_controller(port) \ - nchopper 4 \ - timeout 30 \ - user $chopper_controller(user) \ - password $chopper_controller(password) \ - ] - ChopperAdapter chspeed chopperController speed_1 0 $CH1_MAXSPEED - ChopperAdapter ch2phase chopperController phase_2 0 180 - ChopperAdapter ch3phase chopperController phase_3 0 180 - ChopperAdapter ch4phase chopperController phase_4 0 180 + MakeChopper chopperController tcpdocho [params \ + host $chopper_controller(host) \ + port $chopper_controller(port) \ + nchopper 4 \ + timeout 30 \ + user $chopper_controller(user) \ + password $chopper_controller(password) \ + ] + ChopperAdapter chspeed chopperController speed_1 0 $CH1_MAXSPEED + ChopperAdapter ch2phase chopperController phase_2 0 180 + ChopperAdapter ch3phase chopperController phase_3 0 180 + ChopperAdapter ch4phase chopperController phase_4 0 180 - namespace eval ::chopper { ## # @brief Return TCL_ERROR if chopper is in a state which disallows data acquisition. # This is useful for aborting scans or batch files. - proc ready? {} { - set msg [chopperController status] - if {[lindex $msg 2] == "NOTREADY:"} { - set errmsg "CHOPPER [lrange $msg 2 end]" - return -code error $errmsg - } - } + proc ::chopper::ready? {} { + set msg [chopperController status] + if {[lindex $msg 2] == "NOTREADY:"} { + set errmsg "CHOPPER [lrange $msg 2 end]" + return -code error $errmsg + } + } ## # @brief Return the last known chopper frequency. To get the current frequency you # must issue a 'chopperController update' command first. - proc get_frequency {} { - set msg [split [SplitReply [chopperController frequency]] : ] - if {[lindex $msg 0] == "FAILED"} { - return -code error [lindex $msg 1] - } else { - return $msg - } - } - } + proc ::chopper::get_frequency {} { + set msg [split [SplitReply [chopperController frequency]] : ] + if {[lindex $msg 0] == "FAILED"} { + return -code error [lindex $msg 1] + } else { + return $msg + } + } }