Files
sics/site_ansto/instrument/bilby/config/chopper/chopper.tcl
2014-09-10 15:01:03 +10:00

53 lines
1.7 KiB
Tcl

namespace eval chopper {
variable sim_mode [SplitReply [chopper_simulation]]
set t0_chopper_id_simvar 1
}
if {$sim_mode == false} {
MakeAsyncProtocol std
MakeAsyncQueue chopsel std chopsel1-bilby 30000
}
::utility::macro::getset int t0_chopper_id {args} {
variable sim_mode [SplitReply [chopper_simulation]]
if {$sim_mode == false} {
if {$args == ""} {
chopsel send {get master chopper}
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