Added chopper "ready?" query and "get_frequency" command.

Also added chopper simulation mode.

r2206 | ffr | 2007-10-31 17:00:54 +1100 (Wed, 31 Oct 2007) | 3 lines
This commit is contained in:
Ferdi Franceschini
2007-10-31 17:00:54 +11:00
committed by Douglas Clowes
parent c661cf16a7
commit 03b583655c

View File

@@ -1,4 +1,21 @@
if 0 { set sim_mode [SplitReply [chopper_simulation]]
set CH1_MAXSPEED 1800
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
}
publish ::chopper::ready? user
publish ::chopper::get_frequency user
publish ::chopper::set_frequency user
} else {
# Chopper NCS013 communications # Chopper NCS013 communications
set chopper_controller(host) 137.157.202.130 set chopper_controller(host) 137.157.202.130
set chopper_controller(port) 10000 set chopper_controller(port) 10000
@@ -15,12 +32,33 @@ MakeChopper chopperController tcpdocho [params \
user $chopper_controller(user) \ user $chopper_controller(user) \
password $chopper_controller(password) \ password $chopper_controller(password) \
] ]
ChopperAdapter chspeed chopperController speed 0 10 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 { namespace eval ::chopper {
command set_freq {float: frequency} { ##
for {set i 0} {$i < $frequency} {incr i} { # @brief Return TCL_ERROR if chopper is in a state which disallows data acquisition.
clientput chop # 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
}
}
##
# @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
}
} }
} }
} }