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:
committed by
Douglas Clowes
parent
c661cf16a7
commit
03b583655c
@@ -1,26 +1,64 @@
|
|||||||
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
|
||||||
set chopper_controller(user) NCS
|
set chopper_controller(user) NCS
|
||||||
set chopper_controller(password) NCS013
|
set chopper_controller(password) NCS013
|
||||||
|
|
||||||
|
|
||||||
# CHOPPER
|
# CHOPPER
|
||||||
MakeChopper chopperController tcpdocho [params \
|
MakeChopper chopperController tcpdocho [params \
|
||||||
host $chopper_controller(host) \
|
host $chopper_controller(host) \
|
||||||
port $chopper_controller(port) \
|
port $chopper_controller(port) \
|
||||||
nchopper 4 \
|
nchopper 4 \
|
||||||
timeout 30 \
|
timeout 30 \
|
||||||
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
|
||||||
namespace eval ::chopper {
|
ChopperAdapter ch3phase chopperController phase_3 0 180
|
||||||
command set_freq {float: frequency} {
|
ChopperAdapter ch4phase chopperController phase_4 0 180
|
||||||
for {set i 0} {$i < $frequency} {incr i} {
|
|
||||||
clientput chop
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# @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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user