203 lines
6.2 KiB
Tcl
203 lines
6.2 KiB
Tcl
##
|
|
# @file Definition of common command node procs.
|
|
|
|
################################################################################
|
|
namespace eval commands { }
|
|
|
|
proc ::commands::ic_initialize {} {
|
|
if { ![info exists ::no_histmem] || ($::no_histmem == false) } {
|
|
namespace eval ::histogram {
|
|
set NS [namespace current]
|
|
variable parameters
|
|
array set parameters {mode UNKNOWN preset UNKNOWN freq UNKNOWN frame_source UNKNOWN}
|
|
|
|
command histmem_cmd [subst {
|
|
text=start,stop,pause cmd
|
|
text=[join $::histogram_memory::ic_count_methods , ] mode
|
|
int=0:inf preset
|
|
float freq
|
|
text=[join $::histogram_memory::ic_fsrce_values , ] frame_source
|
|
text=safe,fast cmd_mode
|
|
}] {
|
|
variable parameters
|
|
switch $cmd {
|
|
"stop" {
|
|
histmem stop
|
|
::histogram::histmem_cmd -set feedback status IDLE
|
|
}
|
|
"pause" {
|
|
histmem pause
|
|
::histogram::histmem_cmd -set feedback status PAUSED
|
|
}
|
|
"start" {
|
|
::histogram::histmem_cmd -set feedback status STARTING
|
|
if {$cmd_mode == "fast"} {
|
|
if {$parameters(mode) != $mode} {
|
|
histmem mode $mode
|
|
set parameters(mode) $mode
|
|
}
|
|
if {$parameters(preset) != $preset} {
|
|
histmem preset $preset
|
|
set parameters(preset) $preset
|
|
}
|
|
if {$parameters(freq) != $freq} {
|
|
histmem freq $freq
|
|
set parameters(freq) $freq
|
|
}
|
|
if {$parameters(frame_source) != $frame_source} {
|
|
histmem fsrce $frame_source
|
|
set parameters(frame_source) $frame_source
|
|
}
|
|
} else {
|
|
histmem mode $mode
|
|
histmem preset $preset
|
|
histmem freq $freq
|
|
histmem fsrce $frame_source
|
|
}
|
|
histmem start
|
|
::histogram::histmem_cmd -set feedback status BUSY
|
|
}
|
|
default {
|
|
# $cmd unknown
|
|
}
|
|
}
|
|
}
|
|
::histogram::histmem_cmd -set mode [::histogram_memory::count_method]
|
|
::histogram::histmem_cmd -set preset 0
|
|
::histogram::histmem_cmd -set freq [::histogram_memory::get_frame_freq ]
|
|
::histogram::histmem_cmd -set frame_source [::histogram_memory::get_frame_source ]
|
|
::histogram::histmem_cmd -set cmd_mode "safe"
|
|
::histogram::histmem_cmd -addfb text status
|
|
::histogram::histmem_cmd -set feedback status IDLE
|
|
sicslist setatt ::histogram::histmem_cmd long_name histmem
|
|
sicslist setatt ::histogram::histmem_cmd id histmem
|
|
}
|
|
}
|
|
# SCAN COMMANDS
|
|
namespace eval ::scan {
|
|
set NS [uplevel namespace current]
|
|
|
|
|
|
command hdb_bmonscan {
|
|
text=drivable scan_variable
|
|
float scan_start
|
|
float scan_increment
|
|
int NP
|
|
text=monitor,timer mode
|
|
float preset
|
|
int=0,2 channel
|
|
} {
|
|
|
|
bmonscan clear
|
|
# bmonscan configure script
|
|
|
|
bmonscan add $scan_variable $scan_start $scan_increment
|
|
bmonscan setchannel $channel;
|
|
set status [catch {bmonscan run $NP $mode $preset} msg]
|
|
# bmonscan configure soft
|
|
if {$status == 0} {
|
|
return $msg
|
|
} else {
|
|
return -code error "ERROR [info level 0]"
|
|
}
|
|
|
|
|
|
}
|
|
::scan::hdb_bmonscan -addfb text mode float preset float scan_variable_value int scanpoint int counts text status
|
|
::scan::hdb_bmonscan -set feedback status IDLE
|
|
sicslist setatt ::scan::hdb_bmonscan long_name bmonscan
|
|
|
|
|
|
command runscan_cmd [subst {
|
|
text=drivable scan_variable
|
|
float scan_start
|
|
float scan_stop
|
|
int=0:inf numpoints
|
|
text=[join [concat [list time unlimited period count frame] $::counter::isc_beam_monitor_list ] , ] mode
|
|
float=0,inf preset
|
|
text=[join [array names ::nexus::histmem_filetype_spec] , ] datatype
|
|
text=save,nosave savetype
|
|
text=true,false force
|
|
text=histmem,bmon detector
|
|
}] {
|
|
variable parameters
|
|
|
|
set parameters(mode) $mode
|
|
set parameters(preset) $preset
|
|
::scan::runscan $scan_variable $scan_start $scan_stop $numpoints $mode $preset savetype $savetype datatype $datatype force $force
|
|
}
|
|
::scan::runscan_cmd -set detector "histmem"
|
|
::scan::runscan_cmd -addfb float scan_variable_value float scan_step int scanpoint text status
|
|
::scan::runscan_cmd -set feedback status IDLE
|
|
sicslist setatt ::scan::runscan_cmd long_name runscan
|
|
|
|
}
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
# MONITOR COMMANDS
|
|
namespace eval ::monitor {
|
|
command count {
|
|
text=timer,monitor mode
|
|
float preset
|
|
} {
|
|
::monitor::count -set feedback status BUSY
|
|
bm setmode $mode
|
|
bm count $preset
|
|
::monitor::count -set feedback counts [SplitReply [bm getcounts]];
|
|
}
|
|
::monitor::count -addfb int counts text status
|
|
::monitor::count -set feedback status IDLE
|
|
}
|
|
scriptcallback connect bm COUNTSTART "::monitor::count -set feedback status BUSY"
|
|
scriptcallback connect bm COUNTEND "::monitor::count -set feedback status IDLE"
|
|
################################################################################
|
|
|
|
# Generate the following commands,
|
|
# ::motor::go_home
|
|
namespace eval ::motor {
|
|
set NS [uplevel namespace current]
|
|
if {[info exists is_homing_list] == 0} {
|
|
return -code error "ERROR: Instrument specific command config must set ${NS}::is_homing_list\n"
|
|
}
|
|
command go_home "text=$is_homing_list motors" {
|
|
# Instrument specific command configurations must define
|
|
# ::motor::is_homing_list, this is a possibly empty comma separated list
|
|
# of motors which are safe to send to home
|
|
variable is_homing_list
|
|
|
|
if {$motors == ""} {return}
|
|
set motlist [split $motors ,]
|
|
if {[setdiff $motlist [split $is_homing_list , ]] != ""} {
|
|
return -code error "ERROR: You can only \"home\" a subset of $is_homing_list"
|
|
}
|
|
foreach motor $motlist {
|
|
lappend runargs $motor [SplitReply [$motor home]]
|
|
}
|
|
eval "run $runargs"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Convenience proc for setting the 'runscan' command's detector type
|
|
proc detector {{det "report"}} {
|
|
set det [string tolower $det]
|
|
|
|
switch $det {
|
|
"report" {
|
|
return [::scan::runscan_cmd -get detector]
|
|
}
|
|
"histmem" {
|
|
::scan::runscan_cmd -set detector "histmem"
|
|
}
|
|
"bmon" {
|
|
::scan::runscan_cmd -set detector "bmon"
|
|
}
|
|
default {
|
|
return -code error "ERROR: detector type must be either 'histmem' or bmon' not $det"
|
|
}
|
|
}
|
|
}
|
|
publish detector user
|