sct_protek608.c
Implements a protocol handler for the protek 608 multimeters which just allows us to read the display. It reports all elements of the display including the bar graph, it does not provide remote control of the multimeter. The protocol handler broadcasts a warning to all clients if the auto-off function is enabled. sct_rfamp.c This is a protocol handler for the Mirrortron 35V 7A AC Generator (ANSFR-83B). sinqhttpprot.c Copied the PSI script context http protocol handler. sct_orhvpsprot.c Ordela high voltage power supply protocol handler now catches unknown commands. sct_eurotherm_2000.tcl Eurotherm controller for the kowari load frame by Douglas Clowes. sct_lakeshore_3xx.tcl Latest update from Arndt. The two control loops are now independent, settletime and tolerance now work properly. common_instrument_dictionary.tcl Make instrument/status saveable. sct_orhvps_common.tcl Provides voltage ramping and implements the dhv1 command for the Ordela HVPS via the sct_orhpsprot.c protocol handler. hmm_configuration_common_1.tcl Adds new "histmem clockscale" subcommand to get and set the clock scale from the fat_clock_scale FAT parameter. You can now upload the FAT FRAME_BUFFER and FRAME_DUTYCYCLE parameters to the histogram memory. The veto commands are now "histmem veto on" and "histmem veto off". hmm_object.tcl The axis order for the histmem object has been restore to t,y,x sct_positmotor_common.tcl Code has been simplified. nxscripts_common_1.tcl Removed obsolete ::nexus::data function. TOF axis now correctly report time_of_flight instead of "time". plc_common_1.tcl Make PLC info saveable. scan_common_1.tcl SICS-385 The scan command should check the final scan variable value against he soft upper and lower limits, not against the hard limits. Make sure that the scan variable axis is saved. platypus, kowari, quokka hmm_configuration.tcl Use the HOR and VER entries in the new histmem_axes hash to select the horizontal and vertical axes for the histmem. kowari motor_configuration.tcl secondary_slit_configuration.tcl Flatten slits motor structure to match old layout in data files. quokka commands.tcl SICS-380 EApPosYmm -> EApPosY quokka detector.tcl Use new script context controller for Ordela HVPS quokka hmm_configuration.tcl Set detector height to 5.08*192 the same as the width quokka motor_configuration.tcl Code cleanup quokka positmotor_configuration.tcl Use new positmotor code. quokka aperture_configuration.tcl Added attenuation factor column to AttRotLookupTable quokka parameters.tcl SICS-380 Refactor nexus, remove redundant parameters. site_ansto.c Added the following protocols, Httpl, Protek608, aand RFAmp. scriptcontext.c SICS-386 SctActionHandler: set "send" string to NULL when a chain of scripts completes with state=idle. It turns out that if none of the scripts in the "read chain" call [sct send] each time the chain is executed, then SICS will hammer the device with calls to AsconWrite(). This can be avoided if SctActionHandler sets the 'send' string to NULL before "goto finish" in the idle state. This will be safer and still let you have chains with multiple [sct send] and read scripts. asyncprotocol.c Fix platypus memory leak. devser.c SICS-387 Started adding code to pass signals on to script context drivers. ascon.c AsconTask(): Make sure we return to the AsconIdle state when sending a command which expect no response, also only reconnect if there is a Timeout when there has been an error. r2888 | ffr | 2010-04-19 14:04:41 +1000 (Mon, 19 Apr 2010) | 90 lines
This commit is contained in:
committed by
Douglas Clowes
parent
aa6bb7f1da
commit
d9da95a5df
@@ -39,6 +39,7 @@ SicsUser user sydney 2
|
||||
SicsUser spy 007 3
|
||||
|
||||
MakeDrive
|
||||
InstallHdb
|
||||
|
||||
exe batchpath ../batch
|
||||
exe syspath ../batch
|
||||
|
||||
145
site_ansto/instrument/config/environment/sct_protek_common.tcl
Normal file
145
site_ansto/instrument/config/environment/sct_protek_common.tcl
Normal file
@@ -0,0 +1,145 @@
|
||||
##
|
||||
# @file sct_protek_common.tcl
|
||||
# @brief Gets display state from Protek 608 multimeters.
|
||||
#
|
||||
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
||||
|
||||
## MULTIMETER STATE FIELDS AND VALUES
|
||||
###### MODES
|
||||
# AUTOOFF:1/0 PULSE:1/0 MAX:1/0 PLUSPEAK:1/0 REL:1/0 RECALL:1/0 GO/NG:1/0 MINUSPER:1/0
|
||||
# RS232C:1/0 PLUS:1/0 MINUS:1/0 MIN:1/0 MINUSPEAK:1/0 AVG:1/0 STORE:1/0 REF:1/0 PLUSPER:1/0
|
||||
# LOBAT:1/0
|
||||
|
||||
###### MAIN DISPLAY
|
||||
# AC1:1/0 SIGN1:1/0 DC1:1/0 PW1:1/0
|
||||
# MD5:np MD4:np MD3:np MD2:np MD1:n
|
||||
# M1:1/0 k1:1/0 OHM1:1/0
|
||||
# u1:1/0 Hz1:1/0
|
||||
# m1:1/0 V1:1/0 A1:1/0
|
||||
# n1:1/0 S1:1/0 F1:1/0
|
||||
# DEGC1:1/0 s1:1/0
|
||||
# DEGF1:1/0
|
||||
|
||||
###### BAR GRAPH
|
||||
# B16K:1/0 B8K:1/0 B4K:1/0 B2K:1/0 B1K:1/0
|
||||
# B512:1/0 B256:1/0 B128:1/0 B64:1/0 B32:1/0
|
||||
# B16:1/0 B8:1/0 B4:1/0 B2:1/0 B1:1/0 B0:1/0
|
||||
|
||||
###### SUB DISPLAY
|
||||
# RANGE2:1/0 HOLD2:1/0 DUTY2:1/0
|
||||
# CONT2:1/0 ZD2:1/0
|
||||
# AC2:1/0 SIGN2:1/0 DC2:1/0
|
||||
# SD5:np SD4:np SD3:np SD2:np SD1:n
|
||||
# PERCENT2:1/0 dBm2:1/0
|
||||
# m2:1/0 V2:1/0 A2:1/0 DEGK2:1/0
|
||||
# G2:1/0 M2:1/0 k2:1/0 OHM2:1/0 Hz2:1/0
|
||||
|
||||
# ROTSWITCH:[0-8]
|
||||
|
||||
### The return values for nine bytes is undocumented,
|
||||
### they are labelled as X1 to X9
|
||||
# X[1-9]:?
|
||||
|
||||
##
|
||||
# @brief Sends a state report request to the protek script context protocol handler.
|
||||
proc rqStateRep {} {
|
||||
sct send "STATE"
|
||||
return rdStateRep
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Processes state report from the protek script context protocol handler.
|
||||
proc rdStateRep {} {
|
||||
set stateRep [sct result]
|
||||
if {[string match "ASCERR:*" $stateRep]} {
|
||||
sct geterror $stateRep
|
||||
# Setting oldval forces update and clears geterror on next call
|
||||
sct oldval "UNKNOWN"
|
||||
return idle
|
||||
}
|
||||
|
||||
array set stateArr [split $stateRep "|:"]
|
||||
if {$stateArr(AUTOOFF)} {
|
||||
broadcast "PROTEK608:[sct IP]:[sct PORT] WARNING AUTO OFF IS ENABLED"
|
||||
}
|
||||
if {$stateArr(LOBAT)} {
|
||||
broadcast "PROTEK608: LOW BATTERY WARNING"
|
||||
}
|
||||
if {$stateRep != [sct oldval]} {
|
||||
sct update $stateRep
|
||||
sct oldval $stateRep
|
||||
}
|
||||
return idle
|
||||
}
|
||||
|
||||
proc rqVal {} {
|
||||
return reportVal
|
||||
}
|
||||
proc ProtekMainDisplay {protek} {
|
||||
if [catch {
|
||||
set stateRep [hval $protek/state]
|
||||
set MDpath [sct]
|
||||
set scale [hval $MDpath/scale]
|
||||
set offset [hval $MDpath/offset]
|
||||
array set SA [split $stateRep "|:"]
|
||||
if {$SA(SIGN1)} {
|
||||
set sign1 "-"
|
||||
} else {
|
||||
set sign1 ""
|
||||
}
|
||||
set MDISP "$sign1$SA(MD5)$SA(MD4)$SA(MD3)$SA(MD2)$SA(MD1)"
|
||||
set MDISP [expr {$scale * $MDISP + $offset}]
|
||||
set oldval [sct oldval]
|
||||
if {$MDISP != $oldval} {
|
||||
sct update $MDISP
|
||||
sct oldval $MDISP
|
||||
}
|
||||
} msg ] {
|
||||
return -code error "[info level 0] $msg"
|
||||
}
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Makes a state monitor object for the protek multimeter
|
||||
#
|
||||
# @param name, name of object which reports main display reading
|
||||
# @param IP, IP address of protek moxa box
|
||||
# @param PORT, port number for protek on moxa box
|
||||
# @param scale, scales reading to physical units
|
||||
# @param offset, offset for main display reading
|
||||
# @param interval, polling interval in seconds (optional, default = 0.5seconds)
|
||||
# NOTE: If the interval is negative then the multimeter will be polled on every cycle of
|
||||
# the SICS task loop.
|
||||
proc MakeProtek {name IP PORT {scale 1.0} {offset 0.0} {interval 0.5}} {
|
||||
set sctName "sct_$name"
|
||||
set sobjName "so_$name"
|
||||
set soState "so_state_$name"
|
||||
puts "MakeSICSObj $sobjName SCT_OBJECT"
|
||||
MakeSICSObj $soState SCT_OBJECT
|
||||
MakeSICSObj $sobjName SCT_OBJECT user float
|
||||
sicslist setatt $sobjName long_name $sobjName
|
||||
|
||||
hfactory /sics/$soState/state plain user text
|
||||
hsetprop /sics/$soState/state read rqStateRep
|
||||
hsetprop /sics/$soState/state rdStateRep rdStateRep
|
||||
hsetprop /sics/$soState/state oldval "UNKNOWN"
|
||||
hsetprop /sics/$sobjName read rqVal
|
||||
hsetprop /sics/$sobjName reportVal ProtekMainDisplay /sics/$soState
|
||||
hfactory /sics/$sobjName/scale plain user float
|
||||
hset /sics/$sobjName/scale $scale
|
||||
hfactory /sics/$sobjName/offset plain user float
|
||||
hset /sics/$sobjName/offset $offset
|
||||
hsetprop /sics/$sobjName oldval "UNKNOWN"
|
||||
|
||||
sicslist setatt $sobjName klass sample
|
||||
::scobj::hinitprops $sobjName
|
||||
sicslist setatt $sobjName long_name $name
|
||||
if {[SplitReply [environment_simulation]] == false} {
|
||||
makesctcontroller $sctName protek608 $IP:$PORT
|
||||
hsetprop /sics/$soState/state IP $IP
|
||||
hsetprop /sics/$soState/state PORT $PORT
|
||||
$sctName poll /sics/$soState/state $interval
|
||||
$sctName poll /sics/$sobjName $interval
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -215,7 +215,7 @@ set instrument_dictionary [subst {
|
||||
privilege spy
|
||||
sobj {@any plc}
|
||||
datatype @none
|
||||
property {data false control true nxsave false klass @none type part}
|
||||
property {data true control true nxsave false klass @none type part}
|
||||
}
|
||||
data {
|
||||
privilege spy
|
||||
|
||||
@@ -269,13 +269,27 @@ if {0} {
|
||||
# value on all the servers.
|
||||
proc clock_scale {args} {
|
||||
switch $args {
|
||||
"" { return 1 }
|
||||
"" { return [expr [SplitReply [hmm configure fat_clock_scale]]/1000.0] }
|
||||
"units" { return "microseconds"}
|
||||
default {
|
||||
todo_msg "Set clock_scale as an integer number of nanoseconds"
|
||||
return -code error "[info level 0]: Invalid argument $args"
|
||||
}
|
||||
}
|
||||
}
|
||||
proc get_clock_scale {} {
|
||||
return [SplitReply [hmm configure fat_clock_scale]]
|
||||
}
|
||||
proc set_clock_scale {val} {
|
||||
set catch_status [ catch {
|
||||
if {[string is integer $val] == 0} {
|
||||
error "ERROR: clock scale should be an integer. NOTE: The clock base is in nanoseconds"
|
||||
}
|
||||
hmm configure fat_clock_scale $val
|
||||
::histogram_memory::stop
|
||||
hmm init
|
||||
} message ]
|
||||
handle_exception $catch_status $message
|
||||
}
|
||||
## @brief Use boundaries or centres to calculate axis values
|
||||
#
|
||||
# @param axis_name x_bin, y_bin, x_pixel_offset, y_pixel_offset, two_theta
|
||||
@@ -850,7 +864,7 @@ proc CAT_TABLE {args} {
|
||||
#
|
||||
proc FAT_TABLE {args} {
|
||||
if [ catch {
|
||||
set attributes { FRAME_FREQUENCY SIZE_PERIOD NOS_PERIODS COUNT_METHOD COUNT_SIZE READ_DATA_TYPE VIEW_MAG_X VIEW_MAG_Y HISTO_STREAMING P7888_PLL_FREQ_CARD_X P7888_PLL_FREQ_CARD_Y P7888_CARD_MODE_X P7888_CARD_MODE_Y RAW_HISTO_XMIN RAW_HISTO_XMAX RAW_HISTO_YMIN RAW_HISTO_YMAX TEST_HISTO_1D_SIZES TEST_HISTO_2D_SIZES P7888_PLL_SYNC_METHOD }
|
||||
set attributes { FRAME_FREQUENCY FRAME_BUFFER FRAME_DUTYCYCLE SIZE_PERIOD NOS_PERIODS COUNT_METHOD COUNT_SIZE READ_DATA_TYPE VIEW_MAG_X VIEW_MAG_Y HISTO_STREAMING P7888_PLL_FREQ_CARD_X P7888_PLL_FREQ_CARD_Y P7888_CARD_MODE_X P7888_CARD_MODE_Y RAW_HISTO_XMIN RAW_HISTO_XMAX RAW_HISTO_YMIN RAW_HISTO_YMAX TEST_HISTO_1D_SIZES TEST_HISTO_2D_SIZES P7888_PLL_SYNC_METHOD }
|
||||
|
||||
set elements {{ }}
|
||||
|
||||
@@ -1262,6 +1276,7 @@ proc ::histogram_memory::upload_config {filler_defaults} {
|
||||
# Restore the init level to 0
|
||||
# subesquent inits will only upload specified FAT settings to histogram server.
|
||||
hmm configure init 0
|
||||
hmm init
|
||||
|
||||
# Now issue stop to the server.
|
||||
# This not only makes sure it's stopped, but lets us see certain configuration variables
|
||||
@@ -1394,7 +1409,6 @@ proc ::histogram_memory::set_frame_freq {freq {frame_source EXTERNAL}} {
|
||||
::set newfreq $freq
|
||||
}
|
||||
::histogram_memory::stop
|
||||
set clock_scale_ns 1000.0
|
||||
hmm configure fat_frame_frequency $newfreq
|
||||
hmm init
|
||||
} message ] {
|
||||
@@ -1504,6 +1518,7 @@ proc ::histogram_memory::ic_initialize {} {
|
||||
::histogram_memory::initialise_dictionary
|
||||
::histogram_memory::frame_source_always_internal $default_frame_source_always_internal([instname])
|
||||
::histogram_memory::set_frame_freq 50
|
||||
::histogram_memory::set_clock_scale 1000
|
||||
::histogram_memory::set_frame_source $default_frame_source_when_there_is_no_frame_signal([instname])
|
||||
::histogram_memory::count_method unlimited
|
||||
::histogram_memory::count_size 0
|
||||
@@ -1591,14 +1606,14 @@ proc ::histogram_memory::post_count {} {}
|
||||
|
||||
proc ::histogram_memory::veto {action} {
|
||||
switch $action {
|
||||
"enable" {
|
||||
"on" {
|
||||
if {[status] == "status = Counting"} {
|
||||
hmm veto
|
||||
} else {
|
||||
error "ERROR: veto only allowed while counting"
|
||||
}
|
||||
}
|
||||
"disable" {
|
||||
"off" {
|
||||
if {[status] == "status = Paused"} {
|
||||
hmm noveto
|
||||
} else {
|
||||
@@ -1606,7 +1621,7 @@ proc ::histogram_memory::post_count {} {}
|
||||
}
|
||||
}
|
||||
default {
|
||||
error "ERROR: $action must be 'enable' or 'disable'"
|
||||
error "ERROR: $action must be 'on' or 'off'"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1800,6 +1815,13 @@ namespace eval ::histogram_memory {
|
||||
eval "::histogram_memory::count_size $args"
|
||||
}
|
||||
}
|
||||
"clockscale" {
|
||||
if {$args == ""} {
|
||||
set reply [::histogram_memory::get_clock_scale ]
|
||||
} else {
|
||||
eval "::histogram_memory::set_clock_scale $args"
|
||||
}
|
||||
}
|
||||
"freq" {
|
||||
if {$args == ""} {
|
||||
set reply [::histogram_memory::get_frame_freq ]
|
||||
|
||||
@@ -213,38 +213,38 @@ proc ::histogram_memory::set_axes {typelist} {
|
||||
switch [string toupper $type] {
|
||||
"HISTOGRAM_XYT" - "HISTOPERIOD_XYT" {
|
||||
lappend rank 3
|
||||
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
set dim0 [SplitReply [$HMOBJ configure oat_ntc_eff]]
|
||||
set dim1 [SplitReply [$HMOBJ configure $INST_NYC]]
|
||||
set dim2 [SplitReply [$HMOBJ configure oat_ntc_eff]]
|
||||
set dim2 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
lappend dimstr "$dim0,$dim1,$dim2"
|
||||
lappend hmmslabstart [list 0 0 0]
|
||||
lappend hmmslabend [list $dim0 $dim1 $dim2]
|
||||
lappend hmmperiodsize [expr $dim0 * $dim1 * $dim2]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR VER TOF}]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR TOF VER HOR}]
|
||||
lappend siglist $signal
|
||||
lappend hmmdatname $HMOBJ
|
||||
}
|
||||
"HISTOGRAM_XY" - "HISTOPERIOD_XY" {
|
||||
lappend rank 2
|
||||
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
set dim1 [SplitReply [$HMOBJ configure $INST_NYC]]
|
||||
set dim0 [SplitReply [$HMOBJ configure $INST_NYC]]
|
||||
set dim1 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
lappend dimstr "$dim0,$dim1"
|
||||
lappend hmmslabstart [list 0 0]
|
||||
lappend hmmslabend [list $dim0 $dim1]
|
||||
lappend hmmperiodsize [expr $dim0 * $dim1]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR VER}]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR VER HOR}]
|
||||
lappend siglist $signal
|
||||
lappend hmmdatname "${HMOBJ}_xy"
|
||||
}
|
||||
"HISTOGRAM_XT" - "HISTOPERIOD_XT" {
|
||||
lappend rank 2
|
||||
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
set dim1 [SplitReply [$HMOBJ configure oat_ntc_eff]]
|
||||
set dim0 [SplitReply [$HMOBJ configure oat_ntc_eff]]
|
||||
set dim1 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
lappend dimstr "$dim0,$dim1"
|
||||
lappend hmmslabstart [list 0 0]
|
||||
lappend hmmslabend [list $dim0 $dim1]
|
||||
lappend hmmperiodsize [expr $dim0 * $dim1]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR TOF}]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR TOF HOR}]
|
||||
lappend siglist $signal
|
||||
lappend hmmdatname "${HMOBJ}_xt"
|
||||
}
|
||||
@@ -295,37 +295,37 @@ proc ::histogram_memory::set_axes {typelist} {
|
||||
}
|
||||
"TOTAL_HISTOGRAM_XY" {
|
||||
lappend rank 2
|
||||
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
set dim1 [SplitReply [$HMOBJ configure $INST_NYC]]
|
||||
set dim0 [SplitReply [$HMOBJ configure $INST_NYC]]
|
||||
set dim1 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
lappend dimstr "$dim0,$dim1"
|
||||
lappend hmmslabstart [list 0 0]
|
||||
lappend hmmslabend [list $dim0 $dim1]
|
||||
lappend hmmperiodsize [expr $dim0 * $dim1]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR VER}]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR VER HOR}]
|
||||
lappend siglist $signal
|
||||
lappend hmmdatname "${HMOBJ}_total_xy"
|
||||
}
|
||||
"TOTAL_HISTOGRAM_XY_CORRECTED" {
|
||||
lappend rank 2
|
||||
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
set dim1 [SplitReply [$HMOBJ configure $INST_NYC]]
|
||||
set dim0 [SplitReply [$HMOBJ configure $INST_NYC]]
|
||||
set dim1 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
lappend dimstr "$dim0,$dim1"
|
||||
lappend hmmslabstart [list 0 0]
|
||||
lappend hmmslabend [list $dim0 $dim1]
|
||||
lappend hmmperiodsize [expr $dim0 * $dim1]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR VER}]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR VER HOR}]
|
||||
lappend siglist $signal
|
||||
lappend hmmdatname "${HMOBJ}_total_xy_corrected"
|
||||
}
|
||||
"TOTAL_HISTOGRAM_XT" {
|
||||
lappend rank 2
|
||||
set dim0 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
set dim1 [SplitReply [$HMOBJ configure oat_ntc_eff]]
|
||||
set dim0 [SplitReply [$HMOBJ configure oat_ntc_eff]]
|
||||
set dim1 [SplitReply [$HMOBJ configure $INST_NXC]]
|
||||
lappend dimstr "$dim0,$dim1"
|
||||
lappend hmmslabstart [list 0 0]
|
||||
lappend hmmslabend [list $dim0 $dim1]
|
||||
lappend hmmperiodsize [expr $dim0 * $dim1]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR HOR TOF}]
|
||||
lappend axeslist [::histogram_memory::gen_axes {SVAR TOF HOR}]
|
||||
lappend siglist $signal
|
||||
lappend hmmdatname "${HMOBJ}_total_xt"
|
||||
}
|
||||
|
||||
373
site_ansto/instrument/config/hmm/sct_orhvps_common.tcl
Executable file
373
site_ansto/instrument/config/hmm/sct_orhvps_common.tcl
Executable file
@@ -0,0 +1,373 @@
|
||||
##
|
||||
# @file Implements control for the Ordela high voltage power supply using the odrhvps protocol handler.
|
||||
#
|
||||
# This controller implements voltage ramping and always reads the current value before
|
||||
# attempting to set the new voltage.
|
||||
|
||||
MakeSicsObj so_dhv1 SCT_OBJECT
|
||||
|
||||
namespace eval ::scobj::dethvps { }
|
||||
|
||||
|
||||
##
|
||||
# @brief Requests a value using the given command.
|
||||
#
|
||||
# @param nextSubState, Specifies the state which will handle the reply.
|
||||
# @param cmd, The query command.
|
||||
proc ::scobj::dethvps::rqValue {nextSubState cmd} {
|
||||
set catch_status [ catch {
|
||||
sct send $cmd
|
||||
return $nextSubState
|
||||
} msg ]
|
||||
handle_exception $catch_status $msg
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Processes replies from the voltage controller and controls the
|
||||
# transition between the ramping superstates.
|
||||
#
|
||||
# @param vPath, Hdb node path for the voltage.
|
||||
proc ::scobj::dethvps::rdValue {vPath} {
|
||||
variable RAMPIDLE
|
||||
variable RAMPSTOP
|
||||
variable RAMPSTART
|
||||
variable RAMPBUSY
|
||||
variable MAXPOTVAL
|
||||
variable RAMPINTEREST
|
||||
|
||||
set catch_status [ catch {
|
||||
set data [sct result]
|
||||
set currSuperState [sct ramping]
|
||||
|
||||
switch -glob -- $data {
|
||||
"ASCERR:*" {
|
||||
sct geterror $data
|
||||
if {$currSuperState == $RAMPBUSY || $currSuperState == $RAMPSTART} {
|
||||
broadcast "ERROR: $data, dhv1 stopped ramping detector voltage"
|
||||
statemon stop dhv1
|
||||
} else {
|
||||
# broadcast "ERROR: $data"
|
||||
}
|
||||
if {$currSuperState != $RAMPIDLE} {
|
||||
sct ramping $RAMPIDLE
|
||||
}
|
||||
return idle
|
||||
}
|
||||
default {
|
||||
if {$data != [sct oldval]} {
|
||||
sct geterror ""
|
||||
sct oldval $data
|
||||
sct update $data
|
||||
set voltage [expr [sct max] * $data / double($MAXPOTVAL) ]
|
||||
hset $vPath $voltage
|
||||
if {$RAMPINTEREST} {
|
||||
broadcast "dhv1 = $voltage"
|
||||
}
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
}
|
||||
switch $currSuperState [ subst {
|
||||
$RAMPSTART {
|
||||
sct ramping $RAMPBUSY
|
||||
statemon start dhv1
|
||||
return ramp
|
||||
}
|
||||
$RAMPBUSY {
|
||||
return ramp
|
||||
}
|
||||
$RAMPSTOP {
|
||||
sct ramping $RAMPIDLE
|
||||
statemon stop dhv1
|
||||
return idle
|
||||
}
|
||||
$RAMPIDLE {
|
||||
return idle
|
||||
}
|
||||
default {
|
||||
broadcast "ERROR: dhv1([info level 0]) sct ramping = [sct ramping], STOPPING"
|
||||
sct ramping $RAMPIDLE
|
||||
statemon stop dhv1
|
||||
return idle
|
||||
}
|
||||
} ]
|
||||
} msg ]
|
||||
handle_exception $catch_status $msg
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Checks the target voltage and sets the ramping superstate and ramp direction.
|
||||
proc ::scobj::dethvps::setValue {nextSubState} {
|
||||
variable RAMPIDLE
|
||||
variable RAMPSTOP
|
||||
variable RAMPSTART
|
||||
variable RAMPBUSY
|
||||
|
||||
set catch_status [ catch {
|
||||
set par [sct target]
|
||||
set maxV [sct max]
|
||||
if {$par < 0 || $par > $maxV} {
|
||||
broadcast "ERROR: dhv1 target must be between 0 and $maxV"
|
||||
sct seterror "ERROR: dhv1 target must be between 0 and $maxV"
|
||||
return idle
|
||||
}
|
||||
set currSuperState [sct ramping]
|
||||
set oldval [sct oldval]
|
||||
if {$par == $oldval} {
|
||||
if {$currSuperState == $RAMPBUSY || $currSuperState == $RAMPSTART} {
|
||||
sct ramping $RAMPSTOP
|
||||
}
|
||||
return idle
|
||||
}
|
||||
if {$par < $oldval} {
|
||||
sct rampstep -1
|
||||
} else {
|
||||
sct rampstep 1
|
||||
}
|
||||
if {$currSuperState != $RAMPBUSY && $currSuperState != $RAMPSTART} {
|
||||
sct ramping $RAMPSTART
|
||||
}
|
||||
return $nextSubState
|
||||
} msg ]
|
||||
handle_exception $catch_status $msg
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Checks that a command has been acknowledged
|
||||
proc ::scobj::dethvps::getACK {} {
|
||||
variable RAMPIDLE
|
||||
variable RAMPSTOP
|
||||
variable RAMPSTART
|
||||
variable RAMPBUSY
|
||||
|
||||
set catch_status [ catch {
|
||||
set currSuperState [sct ramping]
|
||||
set data [sct result]
|
||||
switch -glob $data {
|
||||
"ASCERR:*" {
|
||||
sct seterror $data
|
||||
if {$currSuperState == $RAMPBUSY || $currSuperState == $RAMPSTART} {
|
||||
broadcast "ERROR: $data, dhv1 stopped ramping detector voltage"
|
||||
statemon stop dhv1
|
||||
} else {
|
||||
# broadcast "ERROR: $data"
|
||||
}
|
||||
if {$currSuperState != $RAMPSTOP} {
|
||||
sct ramping $RAMPSTOP
|
||||
}
|
||||
return idle
|
||||
}
|
||||
ACK {
|
||||
return idle
|
||||
}
|
||||
default {
|
||||
return idle
|
||||
}
|
||||
}
|
||||
} msg ]
|
||||
handle_exception $catch_status $msg
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Increments or decrements voltage until target has been reached
|
||||
#
|
||||
# @param cmd, The set voltage command
|
||||
proc ::scobj::dethvps::ramping {cmd} {
|
||||
variable RAMPIDLE
|
||||
variable RAMPSTOP
|
||||
variable RAMPSTART
|
||||
variable RAMPBUSY
|
||||
variable MINRAMPINTERVAL
|
||||
|
||||
set catch_status [ catch {
|
||||
set rampstep [sct rampstep]
|
||||
set target [sct target]
|
||||
set oldval [sct oldval]
|
||||
switch -- $rampstep {
|
||||
1 {
|
||||
if {$oldval >= $target} {
|
||||
sct ramping $RAMPSTOP
|
||||
return idle
|
||||
}
|
||||
}
|
||||
-1 {
|
||||
if {$oldval <= $target} {
|
||||
sct ramping $RAMPSTOP
|
||||
return idle
|
||||
}
|
||||
}
|
||||
default {
|
||||
sct ramping $RAMPSTOP
|
||||
broadcast "ERROR: dhv1, Invalid ramp step: $rampstep STOPPING"
|
||||
sct seterror "ERROR: dhv1, Invalid ramp step: $rampstep"
|
||||
return idle
|
||||
}
|
||||
}
|
||||
set target [expr [sct oldval] + [sct rampstep]]
|
||||
sct send "$cmd $target"
|
||||
return getACK
|
||||
} msg ]
|
||||
handle_exception $catch_status $msg
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Command interface for voltage controller
|
||||
proc ::scobj::dethvps::drvCmd {} {
|
||||
variable RAMPIDLE
|
||||
variable RAMPSTOP
|
||||
variable RAMPSTART
|
||||
variable RAMPBUSY
|
||||
variable potValPath
|
||||
|
||||
set catch_status [ catch {
|
||||
set cmd [sct target]
|
||||
switch -- $cmd {
|
||||
"halt" - "stop" {
|
||||
hsetprop $potValPath ramping $RAMPSTOP
|
||||
}
|
||||
"up" {
|
||||
hset $potValPath [sct upper]
|
||||
}
|
||||
"down" {
|
||||
hset $potValPath [sct lower]
|
||||
}
|
||||
"off" {
|
||||
hset $potValPath 0
|
||||
}
|
||||
default {
|
||||
clientput "ERROR: Unknown command $cmd"
|
||||
sct seterror "ERROR: Unknown command $cmd"
|
||||
return idle
|
||||
}
|
||||
}
|
||||
return idle
|
||||
} msg ]
|
||||
handle_exception $catch_status $msg
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Implements the old command line interface for the dhv1 voltage controller.
|
||||
proc ::scobj::dethvps::dhv1 {{CMD getVoltage} {val ""} } {
|
||||
variable RAMPINTEREST
|
||||
variable potValPath
|
||||
variable voltagePath
|
||||
variable cmdPath
|
||||
|
||||
set catch_status [ catch {
|
||||
set qsObjPath ""
|
||||
switch -- $CMD {
|
||||
"list" {
|
||||
clientput "dhv1.interval = [hgetpropval $potValPath interval]"
|
||||
clientput "dhv1.upper = [hgetpropval $cmdPath upper]"
|
||||
clientput "dhv1.lower = [hgetpropval $cmdPath lower]"
|
||||
clientput "dhv1.max = [hgetpropval $potValPath max]"
|
||||
return
|
||||
}
|
||||
"interval" {
|
||||
return "dhv1.interval = [hgetpropval $potValPath interval]"
|
||||
}
|
||||
"max" {
|
||||
set qsObjPath $potValPath
|
||||
}
|
||||
"upper" {
|
||||
if {$val > 63.0} {
|
||||
error "dhv1 upper must be no greater than 63"
|
||||
}
|
||||
set qsObjPath $cmdPath
|
||||
}
|
||||
"lower" {
|
||||
if {$val > 63.0} {
|
||||
error "dhv1 lower must be no greater than 63"
|
||||
}
|
||||
set qsObjPath $cmdPath
|
||||
}
|
||||
"getVoltage" {
|
||||
return "[info level 0 ] = [hval $voltagePath]"
|
||||
}
|
||||
"interest" {
|
||||
set RAMPINTEREST 1
|
||||
statemon interest
|
||||
}
|
||||
"uninterest" {
|
||||
set RAMPINTEREST 0
|
||||
statemon uninterest
|
||||
}
|
||||
"reset" - "lock" - "unlock" - "debug" {
|
||||
return
|
||||
}
|
||||
default {
|
||||
hset $cmdPath $CMD
|
||||
}
|
||||
}
|
||||
if {$qsObjPath != ""} {
|
||||
if {$val != ""} {
|
||||
if {[SplitReply [config myrights]] == 0} {
|
||||
hsetprop $qsObjPath $CMD $val
|
||||
} else {
|
||||
error "ERROR: $CMD can only be initialised from a configuration file"
|
||||
}
|
||||
} else {
|
||||
return "dhv1.$CMD = [hgetpropval $qsObjPath $CMD]"
|
||||
}
|
||||
}
|
||||
} msg ]
|
||||
handle_exception $catch_status $msg
|
||||
}
|
||||
|
||||
namespace eval ::scobj::dethvps {
|
||||
variable RAMPIDLE 0
|
||||
variable RAMPSTOP 1
|
||||
variable RAMPSTART 2
|
||||
variable RAMPBUSY 3
|
||||
variable MINRAMPINTERVAL 10
|
||||
variable RAMPINTEREST 0
|
||||
variable MAXPOTVAL 63.0
|
||||
variable INITMAXVOLTAGE 2600.0
|
||||
variable INITUPPERPOTVAL 57
|
||||
variable INITLOWERPOTVAL 19
|
||||
variable potValPath /sics/so_dhv1/potval
|
||||
variable voltagePath /sics/so_dhv1/voltage
|
||||
variable cmdPath /sics/so_dhv1/cmd
|
||||
|
||||
namespace export dhv1
|
||||
|
||||
hfactory $potValPath plain user int
|
||||
hsetprop $potValPath read ::scobj::dethvps::rqValue rdValue "H"
|
||||
hsetprop $potValPath rdValue ::scobj::dethvps::rdValue $voltagePath
|
||||
hsetprop $potValPath write ::scobj::dethvps::setValue idle
|
||||
hsetprop $potValPath getACK ::scobj::dethvps::getACK
|
||||
hsetprop $potValPath ramp ::scobj::dethvps::ramping "h"
|
||||
hsetprop $potValPath ramping $RAMPIDLE
|
||||
hsetprop $potValPath rampstep 0
|
||||
hsetprop $potValPath oldval -1
|
||||
hsetprop $potValPath max $INITMAXVOLTAGE
|
||||
hsetprop $potValPath interval -1
|
||||
|
||||
hfactory $voltagePath plain internal float
|
||||
hset $voltagePath -1
|
||||
|
||||
hfactory $cmdPath plain user text
|
||||
hsetprop $cmdPath write ::scobj::dethvps::drvCmd
|
||||
hsetprop $cmdPath upper $INITUPPERPOTVAL
|
||||
hsetprop $cmdPath lower $INITLOWERPOTVAL
|
||||
|
||||
}
|
||||
|
||||
proc ::scobj::dethvps::init {host ip rampinterval} {
|
||||
variable potValPath
|
||||
variable voltagePath
|
||||
variable cmdPath
|
||||
variable MINRAMPINTERVAL
|
||||
|
||||
if {[SplitReply [detector_simulation]] == "false"} {
|
||||
makesctcontroller sct_dhv ordhvps $host:$ip
|
||||
set MINRAMPINTERVAL $rampinterval
|
||||
hsetprop $potValPath interval $rampinterval
|
||||
sct_dhv poll $potValPath $rampinterval
|
||||
sct_dhv write $potValPath
|
||||
sct_dhv write $cmdPath
|
||||
}
|
||||
}
|
||||
|
||||
namespace import ::scobj::dethvps::dhv1
|
||||
publish dhv1 user
|
||||
@@ -3,275 +3,115 @@
|
||||
# position. The second column is the motor position.
|
||||
# The lookup table must have a header which names the two columns.
|
||||
|
||||
namespace eval ::scobj::positmotor {
|
||||
variable posit_table
|
||||
variable posit_indices
|
||||
# TODO Add a script to edit the posit_table and attach it to indexed nodes with read and write actions.
|
||||
|
||||
proc abort_on_invalid_posindex {pos motor} {
|
||||
variable posit_indices
|
||||
|
||||
set pos0 [lindex $posit_indices($motor) 0]
|
||||
set posend [lindex $posit_indices($motor) end]
|
||||
if {$pos < $pos0 || $pos > $posend} {
|
||||
return -code error "ERROR: Indexed position must be between $pos0 and $posend"
|
||||
}
|
||||
}
|
||||
proc isbetween {val l1 l2} {
|
||||
if {($l1 <= $val && $val <= $l2) || ($l2 <= $val && $val <= $l1)} {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
proc iswithin {val pos prec} {
|
||||
if {[expr $pos - $prec] <= $val && $val <= [expr $pos + $prec]} {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Convert an indexed position to a physical motor position
|
||||
proc pos2val {pos motor} {
|
||||
variable posit_table
|
||||
|
||||
if [ catch {
|
||||
abort_on_invalid_posindex $pos $motor
|
||||
set bot [expr int(floor($pos))]
|
||||
set top [expr int(ceil($pos))]
|
||||
set fract [expr fmod($pos,1)]
|
||||
set val [expr $fract * ($posit_table($motor,$top) - $posit_table($motor,$bot)) + $posit_table($motor,$bot)]
|
||||
} message ] {
|
||||
return -code error $message
|
||||
} else {
|
||||
return $val
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Convert a physical motor position to and indexed position
|
||||
proc val2pos {val precision motor} {
|
||||
variable posit_table
|
||||
variable posit_indices
|
||||
|
||||
set val [expr double($val)]
|
||||
set pos0 [lindex $posit_indices($motor) 0]
|
||||
set posend [lindex $posit_indices($motor) end]
|
||||
|
||||
if {$posit_table($motor,$pos0) < $posit_table($motor,$posend)} {
|
||||
set fwd_table true
|
||||
if {$val < [expr $posit_table($motor,$pos0) - $precision]} {return -$pos0}
|
||||
if {$val > [expr $posit_table($motor,$posend) + $precision]} {return -$posend}
|
||||
} else {
|
||||
set fwd_table false
|
||||
if {$val < [expr $posit_table($motor,$posend) - $precision]} {return -$posend}
|
||||
if {$val > [expr $posit_table($motor,$pos0) + $precision]} {return -$pos0}
|
||||
}
|
||||
|
||||
if [catch {
|
||||
set ibot $pos0
|
||||
set itop [lindex $posit_indices($motor) 1]
|
||||
if {$fwd_table} {
|
||||
while {$val > [expr $posit_table($motor,$itop) + $precision]} {
|
||||
incr ibot
|
||||
incr itop
|
||||
}
|
||||
} else {
|
||||
while {$val < [expr $posit_table($motor,$itop) - $precision]} {
|
||||
incr ibot
|
||||
incr itop
|
||||
}
|
||||
}
|
||||
set bot [expr $posit_table($motor,$ibot)]
|
||||
set top [expr $posit_table($motor,$itop)]
|
||||
if [iswithin $val $bot $precision] {
|
||||
set pos $ibot
|
||||
} elseif [iswithin $val $top $precision] {
|
||||
set pos $itop
|
||||
} else {
|
||||
# set pos [format "%.3f" [expr int(($val -$bot)/$precision)*$precision/($top - $bot) + $ibot]]
|
||||
set pos [expr abs(int(($val -$bot)/$precision)*$precision/($top - $bot)) + $ibot]
|
||||
}
|
||||
} errmsg] {
|
||||
return -code error $errmsg
|
||||
} else {
|
||||
return $pos
|
||||
}
|
||||
}
|
||||
|
||||
proc rd_index {par motor} {
|
||||
sct result [SplitReply [$motor]]
|
||||
return state_reading_index
|
||||
}
|
||||
namespace eval ::scobj::positmotor { }
|
||||
##
|
||||
# @brief Translate and report the current motor reading.
|
||||
proc ::scobj::positmotor::rptVal {val2IDXfn table precision_node} {
|
||||
set newVal [$val2IDXfn [sct result] [hval $precision_node] $table]
|
||||
if {[sct oldval] != $newVal} {
|
||||
sct update $newVal
|
||||
sct oldval $newVal
|
||||
}
|
||||
set path [sct]
|
||||
if {[hval $path/status] == "STOPPING"} {
|
||||
hset $path/status "IDLE"
|
||||
}
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Updates the position index and sets the associated instrument
|
||||
# parameter
|
||||
#
|
||||
# @param path, Script context object path
|
||||
# @param par, Control parameter for the positional motor
|
||||
# @param motor, The name of the motor which does the actual driving
|
||||
# @param staticpar, The static parameter defined in the lookup table.
|
||||
# @param calc_instpar, Name of an optional function which calculates
|
||||
# the instrument parameter from the staticpar. Eg attenuation
|
||||
proc state_reading_index {path par motor staticpar calc_instpar} {
|
||||
variable posit_table
|
||||
variable posit_label
|
||||
sct writestatus replyreceived
|
||||
set rply [val2pos [sct result] [hval $path/$par/motprecision] $motor]
|
||||
set data $rply
|
||||
# broadcast state_reading_index update parameter $par $data
|
||||
if {$data != [sct oldval] || [sct force_update] } {
|
||||
# if {[status] == "status = Driving" && [hval $path/status] == "IDLE"} {
|
||||
# hset $path/status BUSY
|
||||
# }
|
||||
sct oldval $data
|
||||
sct update $data
|
||||
if {$data > 0 && [string is integer $data]} {
|
||||
if {$calc_instpar == "@none"} {
|
||||
hset $path/$staticpar $posit_label($motor,$data)
|
||||
} else {
|
||||
hset $path/$staticpar [$calc_instpar $posit_label($motor,$data)]
|
||||
}
|
||||
}
|
||||
sct force_update False
|
||||
sct utime readtime
|
||||
}
|
||||
if {[hval $path/status] == "STOPPING"} {
|
||||
hset $path/status IDLE
|
||||
}
|
||||
return idle
|
||||
}
|
||||
|
||||
# Convert position index to a physical position before running the motor
|
||||
proc w_index {sct_controller path par motor} {
|
||||
variable posit_table
|
||||
|
||||
# broadcast w_index
|
||||
if [ catch {
|
||||
set val [pos2val [sct target] $motor]
|
||||
hset $path/status BUSY
|
||||
run $motor $val
|
||||
# $sct_controller poll $path 1
|
||||
} errmsg ] {
|
||||
error $errmsg
|
||||
return noResponse
|
||||
} else {
|
||||
return noResponse
|
||||
}
|
||||
}
|
||||
|
||||
proc noResponse {} {
|
||||
return idle
|
||||
}
|
||||
|
||||
# TODO Check thread 0 and motion control disabled?
|
||||
proc check_motor {} {
|
||||
# broadcast check_motor
|
||||
set val [sct target]
|
||||
return OK
|
||||
}
|
||||
|
||||
proc setposindex {posindex val motor} {
|
||||
variable posit_table
|
||||
|
||||
set posit_table($motor,$posindex) $val
|
||||
}
|
||||
# @brief Request the current motor reading
|
||||
proc ::scobj::positmotor::reqVal {state motor} {
|
||||
sct result [SplitReply [$motor]]
|
||||
return $state
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Create a positional motor control object which lets you
|
||||
# drive to an indexed position defined in a lookup table.
|
||||
# @brief Convert the target position to a motor position and drive the motor to the target.
|
||||
proc ::scobj::positmotor::setVal {ID2valXfn motor table} {
|
||||
set path [sct]
|
||||
set pos [$ID2valXfn [sct target] $table]
|
||||
hset $path/status "BUSY"
|
||||
run $motor $pos
|
||||
return noResponse
|
||||
}
|
||||
|
||||
proc ::scobj::positmotor::noResponse {} {
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Creates a controller which can drive motors to discrete labelled positions
|
||||
#
|
||||
# @param sct_controller, Name of controller created with mk_sct_positmotor
|
||||
# @param klass, Controls place in hdb and nexus file hierarchy.
|
||||
# @param motor, Name of motor which handles the actual driving.
|
||||
# @param scobjName, Name of script-context object which we are creating.
|
||||
# @param pindex, Position index, selects the position to drive to.
|
||||
# @param table_ID, Tag which identifies the lookup table used for this controller.
|
||||
# @param posit_list, Lookup table which maps the index set on the control parameter to a position.
|
||||
# @param calc_instpar, Optional command which returns ????
|
||||
proc mk_sct_positmotor {sct_controller klass motor scobjName pindex table_ID posit_list {calc_instpar @none}} {
|
||||
variable posit_table
|
||||
variable posit_indices
|
||||
variable posit_label
|
||||
|
||||
set index 1
|
||||
set staticpar [lindex $posit_list 0]
|
||||
foreach {label position} [lrange $posit_list 2 end] {
|
||||
lappend posit_indices($motor) $index
|
||||
set posit_table($motor,$index) $position
|
||||
set posit_label($motor,$index) $label
|
||||
incr index
|
||||
}
|
||||
# set posit_indices [lsort -integer [array names posit_table]]
|
||||
|
||||
|
||||
|
||||
if [ catch {
|
||||
# @param sct_controller, name of script-context protocol handler
|
||||
# @param name, name of parameter which corresponds to the discrete motor positions
|
||||
# @param type, float or int
|
||||
# @param motor, name of motor
|
||||
# @param klass, nexus class for parameter
|
||||
# @param table, table of index versus motor positions
|
||||
proc mkPosit {sct_controller name type motor klass table} {
|
||||
set ns ::scobj::positmotor
|
||||
MakeSICSObj $scobjName SCT_OBJECT
|
||||
sicslist setatt $scobjName klass $klass
|
||||
# Make setable position parameter and poll it.
|
||||
set scobjPath /sics/$scobjName
|
||||
hfactory $scobjPath/$pindex plain user float
|
||||
hsetprop $scobjPath/$pindex read ${ns}::rd_index $pindex $motor
|
||||
hsetprop $scobjPath/$pindex state_reading_index ${ns}::state_reading_index $scobjPath $pindex $motor $staticpar $calc_instpar
|
||||
hsetprop $scobjPath/$pindex write ${ns}::w_index $sct_controller $scobjPath $pindex $motor
|
||||
hsetprop $scobjPath/$pindex noResponse ${ns}::noResponse
|
||||
hsetprop $scobjPath/$pindex check ${ns}::check_motor
|
||||
MakeSICSObj $name SCT_OBJECT user $type
|
||||
sicslist setatt $name klass $klass
|
||||
hfactory /sics/$name/precision script "getmotpar $motor precision" "$motor precision " float 1
|
||||
hsetprop /sics/$name read ::scobj::positmotor::reqVal report $motor
|
||||
hsetprop /sics/$name report ::scobj::positmotor::rptVal ::scobj::positmotor::mot2ID $table /sics/$name/precision
|
||||
hsetprop /sics/$name write ::scobj::positmotor::setVal ::scobj::positmotor::ID2mot $motor $table
|
||||
hsetprop /sics/$name noResponse ${ns}::noResponse
|
||||
hsetprop /sics/$name oldval "UNKNOWN"
|
||||
|
||||
hsetprop $scobjPath/$pindex oldval UNKNOWN
|
||||
hsetprop $scobjPath/$pindex force_update True
|
||||
# hsetprop $scobjPath/$pindex motprecision [SplitReply [samx precision]]
|
||||
hfactory $scobjPath/$pindex/motprecision script "getmotpar $motor precision" "$motor precision " float 1
|
||||
hfactory /sics/$name/status plain spy text
|
||||
hset /sics/$name/status "IDLE"
|
||||
|
||||
hfactory $scobjPath/$pindex/lookup_table plain spy none
|
||||
hsetprop $scobjPath/$pindex/lookup_table ID $table_ID
|
||||
hsetprop $scobjPath/$pindex/lookup_table numpos [llength $posit_indices($motor)]
|
||||
foreach posindex $posit_indices($motor) {
|
||||
hfactory $scobjPath/$pindex/lookup_table/$posindex script "${ns}::pos2val $posindex $motor" "${ns}::setposindex $posindex $motor " float 1
|
||||
hsetprop $scobjPath/$pindex/lookup_table/$posindex $staticpar $posit_label($motor,$posindex)
|
||||
}
|
||||
|
||||
hfactory $scobjPath/$staticpar plain user float
|
||||
|
||||
hfactory $scobjPath/status plain spy text
|
||||
hset $scobjPath/status IDLE
|
||||
|
||||
proc ${motor}_MOTEND {} [subst -nocommands {
|
||||
if { [hval $scobjPath/status] == "BUSY"} {
|
||||
# $sct_controller poll $scobjPath/$pindex 5
|
||||
hset $scobjPath/status STOPPING
|
||||
proc ${ns}::${motor}_MOTEND {} [subst -nocommands {
|
||||
if { [hval /sics/$name/status] == "BUSY"} {
|
||||
hset /sics/$name/status "STOPPING"
|
||||
}
|
||||
}]
|
||||
publish ${ns}::${motor}_MOTEND user
|
||||
|
||||
scriptcallback connect $motor MOTEND ${ns}::${motor}_MOTEND
|
||||
$sct_controller poll /sics/$name 2
|
||||
$sct_controller write /sics/$name
|
||||
}
|
||||
|
||||
$sct_controller poll $scobjPath/$pindex 2
|
||||
$sct_controller write $scobjPath/$pindex
|
||||
|
||||
sicslist setatt $scobjName long_name $scobjName
|
||||
|
||||
::scobj::hinitprops $scobjName
|
||||
::scobj::hinitprops $scobjName $pindex
|
||||
::scobj::hinitprops $scobjName $staticpar
|
||||
} message ] {
|
||||
return -code error $message
|
||||
proc ::scobj::positmotor::ID2mot {ID table} {
|
||||
set UID [string toupper $ID]
|
||||
foreach {i m} $table {
|
||||
if {$UID == [string toupper $i]} {
|
||||
return $m
|
||||
}
|
||||
}
|
||||
|
||||
namespace export mk_sct_positmotor
|
||||
return "UNKNOWN"
|
||||
}
|
||||
|
||||
proc ::scobj::positmotor::mot2ID {mot precision table} {
|
||||
set firstMot [lindex $table 1]
|
||||
set lastMot [lindex $table end]
|
||||
if {abs($mot - $firstMot) <= $precision} {
|
||||
return [lindex $table 0]
|
||||
}
|
||||
set sign [expr {$mot - $firstMot}]
|
||||
set iprev [lindex $table 0]
|
||||
set mprev [lindex $table 1]
|
||||
foreach {i m} [lrange $table 2 end] {
|
||||
if {abs($mot - $m) <= $precision} {
|
||||
return $i
|
||||
} elseif {[expr {$sign * ($mot - $m)} ] < 0} {
|
||||
return [expr {($mot-$mprev)*($i - $iprev)/($m - $mprev)+$iprev}]
|
||||
}
|
||||
set iprev $i
|
||||
set mprev $m
|
||||
}
|
||||
return -code error "lookup failed"
|
||||
}
|
||||
|
||||
namespace import ::scobj::positmotor::*
|
||||
##
|
||||
# Eg
|
||||
# hfactory /controllers plain spy none
|
||||
#
|
||||
# makesctcontroller /controllers/sct_mc1 std localhost:62034
|
||||
# makesctcontroller sct_mc3 std localhost:62034
|
||||
#
|
||||
# mk_sct_positmotor sct_mc1 chi index { 1 0 2 15 3 20 }
|
||||
# mkPosit sct_mc3 diameter float apx sample {2.5 0 5.0 -23 7.5 -47}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace eval ::nexus::script {}
|
||||
namespace eval ::histogram_memory {
|
||||
variable histmem_axes
|
||||
array set histmem_axes {
|
||||
TOF /instrument/detector/time
|
||||
TOF /instrument/detector/time_of_flight
|
||||
HOR /instrument/detector/x_pixel_offset
|
||||
VER /instrument/detector/y_pixel_offset
|
||||
PER /instrument/run_number
|
||||
@@ -320,6 +320,9 @@ proc ::nexus::newfile_collection {args} {
|
||||
::hdb::set_save / false
|
||||
nexus_datatype "UNKNOWN"
|
||||
file_set_list "UNKNOWN"
|
||||
foreach l [array names isNewFile] {
|
||||
set isNewFile($l) "false"
|
||||
}
|
||||
# dataFileName "UNKNOWN"
|
||||
} else {
|
||||
foreach hp [split [::nexus::findHdbProps / link]] {
|
||||
@@ -563,9 +566,6 @@ proc ::nexus::save {{point 0}} {
|
||||
# Clears all link targets and sets the data type identifier to unknown
|
||||
# data alias <name>, remove alias <name>
|
||||
# data alias <name> <target>, set <name> as an alias for <target> unless it has already been defined.
|
||||
proc ::nexus::data {args} {
|
||||
# TODO This is obsolete
|
||||
}
|
||||
proc ::nexus::data_junk {args} {
|
||||
variable state
|
||||
variable data_gp_path
|
||||
@@ -792,13 +792,21 @@ proc ::nexus::gen_NXentry_name {baseName} {
|
||||
proc ::nexus::gen_nxdict {nexusdic} {
|
||||
global cfPath
|
||||
variable nxdictionary
|
||||
if [ catch {
|
||||
set catch_status [catch {
|
||||
set nxdict_path $cfPath(nexus)/$nexusdic
|
||||
array unset nxdictionary
|
||||
foreach hp [hlist /] {
|
||||
if {[hgetpropval /$hp data] == true} {
|
||||
set nxclass [hgetpropval /$hp klass]
|
||||
if {[hpropexists /$hp data] } {
|
||||
if {[hgetpropval /$hp data] == true} {
|
||||
if {[hpropexists /$hp klass] } {
|
||||
set nxclass [hgetpropval /$hp klass]
|
||||
} else {
|
||||
error "/$hp does not have a 'klass' attribute"
|
||||
}
|
||||
::nexus::_gen_nxdict $hp /\$(pa_entryName),NXentry $hp $nxclass
|
||||
}
|
||||
} else {
|
||||
error "/$hp does not have a 'data' attribute"
|
||||
}
|
||||
}
|
||||
set fh [open $nxdict_path w]
|
||||
@@ -813,9 +821,8 @@ proc ::nexus::gen_nxdict {nexusdic} {
|
||||
puts $fh "$n = $v"
|
||||
}
|
||||
close $fh
|
||||
} message ] {
|
||||
return -code error "([info level 0]) $message"
|
||||
}
|
||||
} message ]
|
||||
handle_exception $catch_status $message
|
||||
return $nxdict_path
|
||||
}
|
||||
|
||||
@@ -1344,7 +1351,7 @@ set nx_content_release_tag [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
||||
sics_release $nx_content_release_tag
|
||||
sics_release lock
|
||||
|
||||
set tmpstr [string map {"$" ""} {$Revision: 1.51.2.4 $}]
|
||||
set tmpstr [string map {"$" ""} {$Revision: 1.51.2.5 $}]
|
||||
set nx_content_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
||||
|
||||
#namespace eval data {
|
||||
|
||||
@@ -7,7 +7,7 @@ proc ::plc::set_sobj_attributes {} {
|
||||
set objlist [sicslist match plc_*];
|
||||
foreach v $objlist {
|
||||
if { [SplitReply [sicslist $v type]]== "SicsVariable"} {
|
||||
::utility::mkData $v [string replace $v 0 3] plc privilege user control true data false
|
||||
::utility::mkData $v [string replace $v 0 3] plc privilege user control true data true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ if {$sim_mode == "true"} {
|
||||
#
|
||||
# @return 1: if ready, 0: if not ready
|
||||
proc ::plc::inst_ready {} {
|
||||
if {[SplitReply [plc plc_ready]] == "True"} {
|
||||
if {[SplitReply [plc plc_ready]] == "TRUE"} {
|
||||
return 1
|
||||
} else {
|
||||
return 0
|
||||
|
||||
@@ -163,10 +163,10 @@ proc ::scan::check_scanvar {sobj uobj} {
|
||||
} elseif {$check_thread0 && [SplitReply [$scan_variable thread0]] == -1} {
|
||||
return -code error "ERROR: Can't scan ${scan_variable}. Thread zero has stopped running on the motion controller"
|
||||
}
|
||||
set target [expr $scan_start + ($NP-1) * $scan_increment]
|
||||
set scan_final [expr $scan_start + ($NP-1) * $scan_increment]
|
||||
if [catch {
|
||||
::scan::check_limit $scan_variable hardlowerlim $target
|
||||
::scan::check_limit $scan_variable hardupperlim $target
|
||||
::scan::check_limit $scan_variable softlowerlim $scan_final
|
||||
::scan::check_limit $scan_variable softupperlim $scan_final
|
||||
::scan::check_limit $scan_variable softlowerlim $scan_start
|
||||
::scan::check_limit $scan_variable softupperlim $scan_start
|
||||
}] {
|
||||
@@ -211,8 +211,8 @@ proc ::scan::hmm_scan_prepare {sobj uobj} {
|
||||
::scan::runscan_cmd -set feedback status BUSY
|
||||
run_mode "hmscan"
|
||||
|
||||
set ::histogram_memory::histmem_axes(SVAR) [SplitReply [sicslist [::scan::runscan_cmd -set scan_variable] hdb_path] ]
|
||||
::nexus::newfile $ic_hmm_datatype $save_filetype
|
||||
data axis 1 [::scan::runscan_cmd -set scan_variable]
|
||||
|
||||
clientput "Scan start: $scanstart, Scan step: $scanstep, Number of points: $numpoints"
|
||||
clientput "Datatype: $ic_hmm_datatype"
|
||||
@@ -330,8 +330,8 @@ proc ::scan::bm_scan_prepare {sobj uobj} {
|
||||
run_mode "bmonscan"
|
||||
|
||||
array set bm_fb [::scan::hdb_bmonscan -list feedback]
|
||||
set ::histogram_memory::histmem_axes(SVAR) [SplitReply [sicslist [::scan::hdb_bmonscan -set scan_variable] hdb_path] ]
|
||||
::nexus::newfile BEAM_MONITOR data
|
||||
::nexus::data axis 1 [::scan::hdb_bmonscan -set scan_variable]
|
||||
#stdscan prepare $sobj $uobj;
|
||||
clientput "Scan start: $scanstart, Scan step: $scanstep, Number of points: $numpoints"
|
||||
clientput "Datatype: BEAM_MONITOR"
|
||||
|
||||
@@ -51,8 +51,8 @@ proc ::histogram_memory::isc_initialize {} {
|
||||
::histogram_memory::init_OAT_TABLE
|
||||
::histogram_memory::upload_config Filler_defaults
|
||||
|
||||
::nexus::data alias ::histogram_memory::vertical_axis ::histogram_memory::y_bin
|
||||
::nexus::data alias ::histogram_memory::horizontal_axis ::histogram_memory::x_bin
|
||||
set ::histogram_memory::histmem_axes(HOR) /instrument/detector/x_bin
|
||||
set ::histogram_memory::histmem_axes(VER) /instrument/detector/y_bin
|
||||
} message ] {
|
||||
if {$::errorCode=="NONE"} {return $message}
|
||||
return -code error $message
|
||||
|
||||
@@ -4,6 +4,7 @@ config/plc/plc_common_1.tcl
|
||||
config/counter/counter_common_1.tcl
|
||||
config/environment/temperature/sct_lakeshore_3xx.tcl
|
||||
config/environment/temperature/sct_eurotherm_2000.tcl
|
||||
config/environment/sct_protek_common.tcl
|
||||
config/hipadaba/hipadaba_configuration_common.tcl
|
||||
config/hipadaba/common_instrument_dictionary.tcl
|
||||
config/hipadaba/instdict_specification.tcl
|
||||
|
||||
@@ -89,8 +89,8 @@ proc ::histogram_memory::isc_initialize {} {
|
||||
::histogram_memory::init_OAT_TABLE
|
||||
::histogram_memory::upload_config Filler_defaults
|
||||
|
||||
::nexus::data alias ::histogram_memory::vertical_axis ::histogram_memory::y_pixel_offset
|
||||
::nexus::data alias ::histogram_memory::horizontal_axis ::histogram_memory::x_pixel_offset
|
||||
set ::histogram_memory::histmem_axes(HOR) /instrument/detector/x_pixel_offset
|
||||
set ::histogram_memory::histmem_axes(VER) /instrument/detector/y_pixel_offset
|
||||
} message ] {
|
||||
if {$::errorCode=="NONE"} {return $message}
|
||||
return -code error $message
|
||||
|
||||
@@ -597,8 +597,8 @@ Motor psho $motor_driver_type [params \
|
||||
cntsPerX 8192]
|
||||
psho speed 4
|
||||
psho Backlash_offset -0.3
|
||||
psho part slits.primary
|
||||
psho long_name psho
|
||||
psho part slits
|
||||
psho long_name primary_psho
|
||||
setHomeandRange -motor psho -home 0 -lowrange 0 -uprange 30
|
||||
|
||||
# Primary Slit, position 0-150mm (Y-axis)
|
||||
@@ -617,8 +617,8 @@ Motor psp $motor_driver_type [params \
|
||||
cntsPerX -8192]
|
||||
psp speed 4
|
||||
psp Backlash_offset -0.3
|
||||
psp part slits.primary
|
||||
psp long_name psp
|
||||
psp part slits
|
||||
psp long_name primary_psp
|
||||
setHomeandRange -motor psp -home 0 -lowrange 0 -uprange 150
|
||||
|
||||
# Primary Slit, width, 0-30mm
|
||||
@@ -637,8 +637,8 @@ Motor psw $motor_driver_type [params \
|
||||
cntsPerX -8192]
|
||||
psw speed 4
|
||||
psw Backlash_offset 0.3
|
||||
psw part slits.primary
|
||||
psw long_name psw
|
||||
psw part slits
|
||||
psw long_name primary_psw
|
||||
setHomeandRange -motor psw -home 0 -lowrange 0 -uprange 30
|
||||
|
||||
#--------------------------------------------------------
|
||||
@@ -660,8 +660,8 @@ Motor ssho $motor_driver_type [params \
|
||||
cntsPerX 8192]
|
||||
ssho speed 4
|
||||
ssho Backlash_offset -0.3
|
||||
ssho part slits.secondary
|
||||
ssho long_name ssho
|
||||
ssho part slits
|
||||
ssho long_name secondary_ssho
|
||||
setHomeandRange -motor ssho -home 0 -lowrange 0 -uprange 30
|
||||
|
||||
# Secondary Slit, position
|
||||
@@ -680,8 +680,8 @@ Motor ssp $motor_driver_type [params \
|
||||
cntsPerX -8192]
|
||||
ssp speed 4
|
||||
ssp Backlash_offset -0.3
|
||||
ssp part slits.secondary
|
||||
ssp long_name ssp
|
||||
ssp part slits
|
||||
ssp long_name secondary_ssp
|
||||
setHomeandRange -motor ssp -home 0 -lowrange 0 -uprange 150
|
||||
|
||||
# Primary Slit, height, 0-30mm
|
||||
@@ -698,8 +698,8 @@ setHomeandRange -motor ssp -home 0 -lowrange 0 -uprange 150
|
||||
# absenc 1\
|
||||
# absenchome 542093\
|
||||
# cntsPerX 8192]
|
||||
#psh part slits.primary
|
||||
#psh long_name psh
|
||||
#psh part slits
|
||||
#psh long_name primary_psh
|
||||
#setHomeandRange -motor psh -home 0 -lowrange 0 -uprange 30
|
||||
|
||||
## Secondary Slit, height
|
||||
@@ -716,8 +716,8 @@ setHomeandRange -motor ssp -home 0 -lowrange 0 -uprange 150
|
||||
# absenc 1\
|
||||
# absenchome 500000\
|
||||
# cntsPerX 8192]
|
||||
#ssh part slits.secondary
|
||||
#ssh long_name ssh
|
||||
#ssh part slits
|
||||
#ssh long_name secondary_ssh
|
||||
#setHomeandRange -motor ssh -home 0 -lowrange 0 -uprange 30
|
||||
|
||||
#--------------------------------------------------------
|
||||
|
||||
@@ -16,6 +16,6 @@ Motor ssw $motor_driver_type [params \
|
||||
cntsPerX -8192]
|
||||
ssw speed 4
|
||||
ssw Backlash_offset 0.3
|
||||
ssw part slits.secondary
|
||||
ssw long_name ssw
|
||||
ssw part slits
|
||||
ssw long_name secondary_ssw
|
||||
setHomeandRange -motor ssw -home 0 -lowrange 0 -uprange 30
|
||||
|
||||
@@ -24,6 +24,7 @@ fileeval $cfPath(plc)/plc.tcl
|
||||
fileeval $cfPath(counter)/counter.tcl
|
||||
fileeval $cfPath(environment)/temperature/sct_lakeshore_3xx.tcl
|
||||
fileeval $cfPath(environment)/temperature/sct_eurotherm_2000.tcl
|
||||
fileeval $cfPath(environment)/sct_protek_common.tcl
|
||||
fileeval $cfPath(hmm)/hmm_configuration.tcl
|
||||
fileeval $cfPath(nexus)/nxscripts.tcl
|
||||
fileeval $cfPath(scan)/scan.tcl
|
||||
|
||||
@@ -8,6 +8,7 @@ config/hipadaba/instdict_specification.tcl
|
||||
config/hmm/hmm_configuration_common_1.tcl
|
||||
config/hmm/hmm_object.tcl
|
||||
config/hmm/anstohm_linked.xml
|
||||
config/hmm/sct_orhvps_common.tcl
|
||||
config/scan/scan_common_1.hdd
|
||||
config/scan/scan_common_1.tcl
|
||||
config/nexus/nxscripts_common_1.tcl
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace eval optics {
|
||||
}
|
||||
::optics::guide -set feedback status BUSY
|
||||
set msg [eval "drive $to_config"]
|
||||
EApPosYmm $position
|
||||
EApPosY $position
|
||||
}
|
||||
GuideConfig $configuration
|
||||
} message ] {
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
# Detector voltage controller
|
||||
|
||||
set sim_mode [SplitReply [detector_simulation]]
|
||||
|
||||
if {$::sim_mode == "true"} {
|
||||
EvFactory new dhv1 sim
|
||||
} else {
|
||||
makeasyncqueue acq ORHVPS ca1-quokka 4001
|
||||
evfactory new dhv1 orhvps acq
|
||||
dhv1 lowerlimit 0
|
||||
dhv1 upperlimit 2400
|
||||
dhv1 tolerance 19
|
||||
dhv1 max 2600
|
||||
dhv1 rate 10
|
||||
dhv1 debug 1
|
||||
dhv1 unlock
|
||||
dhv1 debug 0
|
||||
# dhv1 lock
|
||||
}
|
||||
|
||||
fileeval $cfPath(hmm)/sct_orhvps_common.tcl
|
||||
::scobj::dethvps::init ca1-quokka 4001 4.1
|
||||
dhv1 max 2600
|
||||
dhv1 lower 19
|
||||
dhv1 upper 57
|
||||
|
||||
@@ -39,10 +39,10 @@ proc ::histogram_memory::isc_initialize {} {
|
||||
FAT_TABLE -init
|
||||
::histogram_memory::ic_initialize
|
||||
|
||||
detector_active_height_mm 980
|
||||
detector_active_width_mm [expr 5.08 * 192]
|
||||
detector_active_height_mm [expr 5.08 * 192]
|
||||
detector_active_width_mm [expr 5.08 * 192]
|
||||
detector_active_height_mm lock
|
||||
detector_active_width_mm lock
|
||||
detector_active_width_mm lock
|
||||
|
||||
# hmm configure FAT_SIMULATED_EVENT_Y0 $y_bb0
|
||||
# hmm configure FAT_SIMULATED_EVENT_Y1 $ybbmax
|
||||
@@ -51,8 +51,8 @@ proc ::histogram_memory::isc_initialize {} {
|
||||
::histogram_memory::init_OAT_TABLE
|
||||
::histogram_memory::upload_config Filler_defaults
|
||||
|
||||
::nexus::data alias ::histogram_memory::vertical_axis ::histogram_memory::y_pixel_offset
|
||||
::nexus::data alias ::histogram_memory::horizontal_axis ::histogram_memory::x_pixel_offset
|
||||
set ::histogram_memory::histmem_axes(HOR) /instrument/detector/x_pixel_offset
|
||||
set ::histogram_memory::histmem_axes(VER) /instrument/detector/y_pixel_offset
|
||||
} message ] {
|
||||
return -code error $message
|
||||
}
|
||||
|
||||
@@ -840,7 +840,6 @@ bs1 softlowerlim 11
|
||||
bs1 softupperlim 95
|
||||
bs1 home 90
|
||||
bs1 precision 0.05
|
||||
sicslist setatt bs1 link parameters_group
|
||||
|
||||
Motor bs2 $motor_driver_type [params \
|
||||
asyncqueue mc4\
|
||||
@@ -861,7 +860,6 @@ bs2 softlowerlim 7
|
||||
bs2 softupperlim 95
|
||||
bs2 home 90
|
||||
bs2 precision 0.05
|
||||
sicslist setatt bs2 link parameters_group
|
||||
|
||||
Motor bs3 $motor_driver_type [params \
|
||||
asyncqueue mc4\
|
||||
@@ -882,7 +880,6 @@ bs3 softlowerlim 11
|
||||
bs3 softupperlim 95
|
||||
bs3 home 90
|
||||
bs3 precision 0.05
|
||||
sicslist setatt bs3 link parameters_group
|
||||
|
||||
Motor bs4 $motor_driver_type [params \
|
||||
asyncqueue mc4\
|
||||
@@ -903,7 +900,6 @@ bs4 softlowerlim 7
|
||||
bs4 softupperlim 95
|
||||
bs4 home 90
|
||||
bs4 precision 0.05
|
||||
sicslist setatt bs4 link parameters_group
|
||||
|
||||
Motor bs5 $motor_driver_type [params \
|
||||
asyncqueue mc4\
|
||||
@@ -924,7 +920,6 @@ bs5 softlowerlim 11
|
||||
bs5 softupperlim 95
|
||||
bs5 home 90
|
||||
bs5 precision 0.05
|
||||
sicslist setatt bs5 link parameters_group
|
||||
|
||||
Motor bs6 $motor_driver_type [params \
|
||||
asyncqueue mc4\
|
||||
@@ -945,7 +940,6 @@ bs6 softlowerlim 7
|
||||
bs6 softupperlim 95
|
||||
bs6 home 90
|
||||
bs6 precision 0.05
|
||||
sicslist setatt bs6 link parameters_group
|
||||
|
||||
# Polarizer Rotation
|
||||
#Motor pol $motor_driver_type [params \
|
||||
|
||||
@@ -10,8 +10,8 @@ makesctcontroller sct_mc3 std mc3:$port3
|
||||
makesctcontroller sct_mc4 std mc4:$port4
|
||||
|
||||
# label pos
|
||||
#index position
|
||||
set 20sample_table {
|
||||
index position
|
||||
1 453.7
|
||||
2 411.7
|
||||
3 369.7
|
||||
@@ -34,10 +34,10 @@ index position
|
||||
20 -464.3
|
||||
}
|
||||
|
||||
mk_sct_positmotor sct_mc1 parameter samx changer_position samplenum 20SAMPLES $20sample_table
|
||||
mkPosit sct_mc1 sampleNum float samx sample $20sample_table
|
||||
|
||||
#diameter position
|
||||
set auto_ap_table {
|
||||
diameter position
|
||||
2.5 0
|
||||
5.0 -23
|
||||
7.5 -47
|
||||
@@ -49,5 +49,5 @@ diameter position
|
||||
25.0 -215
|
||||
30.0 -250
|
||||
}
|
||||
mk_sct_positmotor sct_mc3 parameter apx autoSampleAp aperture auto_ap $auto_ap_table
|
||||
mkPosit sct_mc3 diameter float apx sample $auto_ap_table
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
namespace eval optics {
|
||||
array set AttRotLookupTable {
|
||||
0 0.0
|
||||
30 1.3
|
||||
60 3.3
|
||||
90 4.9
|
||||
120 6.4
|
||||
150 8.3
|
||||
180 9.6
|
||||
210 11.2
|
||||
240 13.1
|
||||
270 15.0
|
||||
300 18.0
|
||||
330 25.0
|
||||
0 { 0.0 1 }
|
||||
30 { 1.3 0.498782 }
|
||||
60 { 3.3 0.176433 }
|
||||
90 { 4.9 0.0761367 }
|
||||
120 { 6.4 0.0353985 }
|
||||
150 { 8.3 0.0137137 }
|
||||
180 { 9.6 0.00614167 }
|
||||
210 {11.2 0.00264554 }
|
||||
240 {13.1 0.000994504 }
|
||||
270 {15.0 0.000358897 }
|
||||
300 {18.0 7.2845e-05 }
|
||||
330 {25.0 1.67827e-06 }
|
||||
}
|
||||
|
||||
array set EApLookupTable {
|
||||
@@ -30,20 +30,29 @@ namespace eval optics {
|
||||
}
|
||||
}
|
||||
|
||||
proc ::optics::AttRotLookup {angle tol} {
|
||||
proc ::optics::AttRotLookup {angle column tol} {
|
||||
variable AttRotLookupTable
|
||||
set foundit false
|
||||
foreach vangle [array names AttRotLookupTable] {
|
||||
if {$vangle >= [expr {$angle-$tol}] && $vangle <= [expr {$angle+$tol}]} {
|
||||
set foundit true
|
||||
break
|
||||
}
|
||||
}
|
||||
if {$foundit == true} {
|
||||
return [lindex $AttRotLookupTable($vangle) 0]
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
|
||||
set catch_status [ catch {
|
||||
set foundit false
|
||||
foreach vangle [array names AttRotLookupTable] {
|
||||
if {$vangle >= [expr {$angle-$tol}] && $vangle <= [expr {$angle+$tol}]} {
|
||||
set foundit true
|
||||
break
|
||||
}
|
||||
}
|
||||
if {$foundit == true} {
|
||||
switch $column {
|
||||
"plex" { set index 0 }
|
||||
"attfactor" { set index 1 }
|
||||
default { error "$column is unknown, allowed values are plex or attfactor" }
|
||||
}
|
||||
return [lindex $AttRotLookupTable($vangle) $index]
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
} message ]
|
||||
handle_exception $catch_status $message
|
||||
}
|
||||
|
||||
proc ::optics::EApLookUp {angle param tol} {
|
||||
|
||||
@@ -11,7 +11,6 @@ foreach {var lname type priv units klass} {
|
||||
BeamCenterZ BeamCenterZ float user mm parameter
|
||||
BeamStop BeamStop int user none parameter
|
||||
BSdiam BSdiam float user mm parameter
|
||||
DetPosYOffset DetPosYOffset float user mm parameter
|
||||
EApPosY EApPosY float user mm parameter
|
||||
EndFacePosY EndFacePosY float readonly mm parameter
|
||||
GuideConfig GuideConfig text user none parameter
|
||||
@@ -30,22 +29,19 @@ foreach {var lname type priv units klass} {
|
||||
|
||||
proc sicsmsgfmt {args} {return "[info level -1] = $args"}
|
||||
|
||||
::utility::macro::getset float SamplePosY {} {
|
||||
set sy [SplitReply [samy]]
|
||||
set syo [SplitReply [SamYOffset]]
|
||||
return [sicsmsgfmt [expr {$sy+$syo}]]
|
||||
}
|
||||
sicslist setatt SamplePosY long_name SamplePosY
|
||||
sicslist setatt SamplePosY klass parameter
|
||||
sicslist setatt SamplePosY units mm
|
||||
|
||||
::utility::macro::getset float Plex {} {
|
||||
return [sicsmsgfmt [ ::optics::AttRotLookup [SplitReply [att]] [SplitReply [att precision]] ]]
|
||||
return [sicsmsgfmt [ ::optics::AttRotLookup [SplitReply [att]] "plex" [SplitReply [att precision]] ]]
|
||||
}
|
||||
sicslist setatt Plex units mm
|
||||
sicslist setatt Plex long_name Plex
|
||||
sicslist setatt Plex klass parameter
|
||||
|
||||
::utility::macro::getset float AttFactor {} {
|
||||
return [sicsmsgfmt [ ::optics::AttRotLookup [SplitReply [att]] "attfactor" [SplitReply [att precision]] ]]
|
||||
}
|
||||
sicslist setatt AttFactor long_name AttFactor
|
||||
sicslist setatt AttFactor klass parameter
|
||||
|
||||
::utility::macro::getset float EApX {} {
|
||||
return [sicsmsgfmt [::optics::EApLookUp [SplitReply [srce]] "size" [SplitReply [srce precision]] ]]
|
||||
}
|
||||
@@ -69,7 +65,7 @@ sicslist setatt EApShape mutable false
|
||||
|
||||
::utility::macro::getset float L1 {} {
|
||||
set efpy [SplitReply [EndFacePosY]]
|
||||
set samposy [SplitReply [SamplePosY]]
|
||||
set samposy [SplitReply [samy]]
|
||||
set eapy [SplitReply [EApPosY]]
|
||||
return [sicsmsgfmt [expr {$efpy + $samposy - $eapy}]]
|
||||
}
|
||||
@@ -79,9 +75,8 @@ sicslist setatt L1 units mm
|
||||
|
||||
::utility::macro::getset float L2 {} {
|
||||
set detpy [SplitReply [det]]
|
||||
set detpyos [SplitReply [DetPosYOffset]]
|
||||
set sapy [SplitReply [SamplePosY]]
|
||||
return [sicsmsgfmt [expr {$detpy + $detpyos - $sapy}]]
|
||||
set sapy [SplitReply [samy]]
|
||||
return [sicsmsgfmt [expr {$detpy - $sapy}]]
|
||||
}
|
||||
sicslist setatt L2 long_name L2
|
||||
sicslist setatt L2 klass parameter
|
||||
@@ -114,7 +109,6 @@ namespace eval parameters {
|
||||
set paramlist {
|
||||
AttFactor
|
||||
BSdiam
|
||||
DetPosYOffset
|
||||
EApPosY
|
||||
EApShape
|
||||
EApX
|
||||
@@ -124,7 +118,6 @@ namespace eval parameters {
|
||||
L2
|
||||
Plex
|
||||
SamYOffset
|
||||
SamplePosY
|
||||
Transmission
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user