61 lines
2.3 KiB
Tcl
61 lines
2.3 KiB
Tcl
|
|
namespace eval chopper {
|
|
variable sim_mode [SplitReply [chopper_simulation]]
|
|
set t0_chopper_id_simvar 1
|
|
}
|
|
|
|
if {$::chopper::sim_mode == false} {
|
|
MakeAsyncProtocol chopsel_ap
|
|
chopsel_ap sendterminator "0x0D0x0A0"
|
|
# Append space to reply terminator to match terminator from the 'get master chopper' reply
|
|
chopsel_ap replyterminator "0x0D0x0A00x20"
|
|
MakeAsyncQueue chopsel chopsel_ap chopsel1-bilby 30000
|
|
# Set timeout to 100ms to improve response for all the other replies that just end with crlf
|
|
chopsel timeout 100
|
|
# Send something to get the dopey welcome and help messages out of the way
|
|
chopsel send x
|
|
}
|
|
::utility::macro::getset int t0_chopper_id {args} {
|
|
if {$::chopper::sim_mode == false} {
|
|
if {$args == ""} {
|
|
return "t0_chopper_id = [SplitReply [chopsel send {get master chopper}]]"
|
|
} else {
|
|
chopsel send "get master chopper"
|
|
chopsel send "enable chopper selection"
|
|
chopsel send "set master chopper=$args"
|
|
chopsel send "disable chopper selection"
|
|
}
|
|
} else {
|
|
if {$args == ""} {
|
|
if {$::chopper::t0_chopper_id_simvar < 1 || $::chopper::t0_chopper_id_simvar > 4} {
|
|
return -code error "Your simulated chopper returned an error"
|
|
} else {
|
|
return "t0_chopper_id = $::chopper::t0_chopper_id_simvar"
|
|
}
|
|
} else {
|
|
set ::chopper::t0_chopper_id_simvar $args
|
|
}
|
|
}
|
|
}
|
|
sicslist setatt t0_chopper_id klass NXdisk_chopper
|
|
sicslist setatt t0_chopper_id long_name t0_chopper_id
|
|
sicslist setatt t0_chopper_id mutable true
|
|
|
|
if [dict exists $::config_dict disk_chopper name] {
|
|
set ch_name [dict get $::config_dict disk_chopper name]
|
|
} else {
|
|
clientput ERROR: Chopper configuration is missing
|
|
}
|
|
::utility::macro::getset float t0_chopper_freq [subst { {chopper $ch_name} }] {
|
|
set cid [SplitReply [t0_chopper_id]]
|
|
set freq [hval /instrument/$chopper/disk_$cid/frequency]
|
|
return "t0_chopper_freq = $freq"
|
|
}
|
|
sicslist setatt t0_chopper_freq klass NXdisk_chopper
|
|
sicslist setatt t0_chopper_freq long_name t0_chopper_freq
|
|
sicslist setatt t0_chopper_freq mutable true
|
|
::utility::mkVar master_chopper_id int user master_chopper_id true NXdisk_chopper true true
|
|
::utility::mkVar master_chopper_freq float user master_chopper_freq true NXdisk_chopper true true
|
|
::utility::mkVar t0_chopper_phase float user t0_chopper_phase true NXdisk_chopper true true
|
|
|