Some code cleanup.

r2218 | ffr | 2007-11-01 13:04:31 +1100 (Thu, 01 Nov 2007) | 2 lines
This commit is contained in:
Ferdi Franceschini
2007-11-01 13:04:31 +11:00
committed by Douglas Clowes
parent 6308cd312a
commit 8d3817c9ef

View File

@@ -1,17 +1,18 @@
set sim_mode [SplitReply [chopper_simulation]] set sim_mode [SplitReply [chopper_simulation]]
set CH1_MAXSPEED 1800 set CH1_MAXSPEED 1800
namespace eval ::chopper {}
if {$sim_mode == "true"} { if {$sim_mode == "true"} {
MakeChopper chopperController sim MakeChopper chopperController sim
ChopperAdapter chspeed chopperController speed 0 $CH1_MAXSPEED ChopperAdapter chspeed chopperController speed 0 $CH1_MAXSPEED
ChopperAdapter ch2phase chopperController phase 0 180 ChopperAdapter ch2phase chopperController phase 0 180
ChopperAdapter ch3phase chopperController phase 0 180 ChopperAdapter ch3phase chopperController phase 0 180
ChopperAdapter ch4phase chopperController phase 0 180 ChopperAdapter ch4phase chopperController phase 0 180
namespace eval ::chopper { proc ::chopper::ready? {} {}
proc ready? {} {} proc ::chopper::get_frequency {} {variable frequency; return $frequency}
proc get_frequency {} {variable frequency; return $frequency} proc ::chopper::set_frequency {freq} {variable frequency; set frequency $freq}
proc set_frequency {freq} {variable frequency; set frequency $freq} ::chopper::set_frequency 0
set_frequency 0
}
publish ::chopper::ready? user publish ::chopper::ready? user
publish ::chopper::get_frequency user publish ::chopper::get_frequency user
publish ::chopper::set_frequency user publish ::chopper::set_frequency user
@@ -37,11 +38,10 @@ if {$sim_mode == "true"} {
ChopperAdapter ch3phase chopperController phase_3 0 180 ChopperAdapter ch3phase chopperController phase_3 0 180
ChopperAdapter ch4phase chopperController phase_4 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. # @brief Return TCL_ERROR if chopper is in a state which disallows data acquisition.
# This is useful for aborting scans or batch files. # This is useful for aborting scans or batch files.
proc ready? {} { proc ::chopper::ready? {} {
set msg [chopperController status] set msg [chopperController status]
if {[lindex $msg 2] == "NOTREADY:"} { if {[lindex $msg 2] == "NOTREADY:"} {
set errmsg "CHOPPER [lrange $msg 2 end]" set errmsg "CHOPPER [lrange $msg 2 end]"
@@ -52,7 +52,7 @@ if {$sim_mode == "true"} {
## ##
# @brief Return the last known chopper frequency. To get the current frequency you # @brief Return the last known chopper frequency. To get the current frequency you
# must issue a 'chopperController update' command first. # must issue a 'chopperController update' command first.
proc get_frequency {} { proc ::chopper::get_frequency {} {
set msg [split [SplitReply [chopperController frequency]] : ] set msg [split [SplitReply [chopperController frequency]] : ]
if {[lindex $msg 0] == "FAILED"} { if {[lindex $msg 0] == "FAILED"} {
return -code error [lindex $msg 1] return -code error [lindex $msg 1]
@@ -60,5 +60,4 @@ if {$sim_mode == "true"} {
return $msg return $msg
} }
} }
}
} }