|
|
|
|
@@ -2,19 +2,46 @@
|
|
|
|
|
|
|
|
|
|
proc ord_get_pot { potxy potnumber } {
|
|
|
|
|
for { set rsp "Bad" } { $rsp == "Bad" } { } {
|
|
|
|
|
set potname [ format "%s%d" $potxy [expr $potnumber ^ 3] ]
|
|
|
|
|
# set potname [ format "%s%d" $potxy [expr $potnumber ^ 3] ]
|
|
|
|
|
# set rspall [ dhv1 cmd P $potname ]
|
|
|
|
|
set rspall [ sct_dhv1 transact "P $potname" ]
|
|
|
|
|
# NOTE: new driver (ie sct_dhv) re-orders lower 2 bits
|
|
|
|
|
set potname [ format "%s%d" $potxy $potnumber ]
|
|
|
|
|
set rspall [ sct_dhv transact "P $potname" ]
|
|
|
|
|
set rsp [lindex [split $rspall " "] 1]
|
|
|
|
|
# MJL sometimes the driver returns '=' or '', fix that...
|
|
|
|
|
# ALSO the driver sometimes returns TCL internal strings, reject non-numeric data
|
|
|
|
|
# ALSO the driver sometimes returns 65, fix that (range 0 to 63)
|
|
|
|
|
set rspval 0
|
|
|
|
|
if { $rsp == "=" || $rsp == "" || [scan $rsp %d rspval] != 1 } { set rsp "Bad" }
|
|
|
|
|
if { $rspval < 0 } { set rspval 0 }
|
|
|
|
|
if { $rspval > 63 } { set rspval 63 }
|
|
|
|
|
}
|
|
|
|
|
return $rsp
|
|
|
|
|
return $rspval
|
|
|
|
|
}
|
|
|
|
|
Publish ord_get_pot User
|
|
|
|
|
|
|
|
|
|
proc ord_set_pot { potxy potnumber potvalue } {
|
|
|
|
|
set potname [ format "%s%d" $potxy [expr $potnumber ^ 3] ]
|
|
|
|
|
# set potname [ format "%s%d" $potxy [expr $potnumber ^ 3] ]
|
|
|
|
|
# set rsp [ dhv1 cmd p $potname $potvalue ]
|
|
|
|
|
set rsp [ sct_dhv1 transact "p $potname $potvalue" ]
|
|
|
|
|
# NOTE: new driver (ie sct_dhv) re-orders lower 2 bits
|
|
|
|
|
# MJL 9/10 Added retry code in case write failed.
|
|
|
|
|
for { set rsp "Bad" } { $rsp == "Bad" } { } {
|
|
|
|
|
set potname [ format "%s%d" $potxy $potnumber ]
|
|
|
|
|
# MJL It seems that the pots can somehow get set to '65'. I believe this might be returned when the read
|
|
|
|
|
# is invalid (e.g. perhaps the read query is corrupted, then the pot index is out of range and the controller
|
|
|
|
|
# responds with '65' to let us know that). So it happened that some read pot values appeared to be '65'.
|
|
|
|
|
# But if the sct_dhv transact ever attempts to send '65' to a pot, it seems that it hangs forever.
|
|
|
|
|
# Another problem in the driver... Just limit the value to 0 - 63 as it should be
|
|
|
|
|
if { $potvalue < 0 } { set potvalue 0 }
|
|
|
|
|
if { $potvalue > 63 } { set potvalue 63 }
|
|
|
|
|
#clientput "About to transact: " $potname " " $potvalue
|
|
|
|
|
set rsp [ sct_dhv transact "p $potname $potvalue" ]
|
|
|
|
|
# MJL sometimes the driver returns absolute bollocks, looks like strings from inside the TCL interpreter.
|
|
|
|
|
# Under this condition, assume the write failed, although we can't really tell without reading back value, but don't bother.
|
|
|
|
|
# Just flag anything that's not 'ACK' as 'Bad' i.e. do retries.
|
|
|
|
|
# clientput "Response:" $rsp
|
|
|
|
|
if { $rsp != "ACK" } { set rsp "Bad" }
|
|
|
|
|
}
|
|
|
|
|
return $rsp
|
|
|
|
|
}
|
|
|
|
|
Publish ord_set_pot User
|
|
|
|
|
@@ -133,6 +160,27 @@ proc ord_load_pot_all { filename } {
|
|
|
|
|
}
|
|
|
|
|
Publish ord_load_pot_all User
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ord_load_pot_all_old_format { filename } {
|
|
|
|
|
# When saved by the 21000N software, the first row is y in reversed order and the second row is x in normal order
|
|
|
|
|
# This routine reads the file, then reorders the values to normal x then y order
|
|
|
|
|
ord_load_pot_all $filename
|
|
|
|
|
global ord_pot_all_x
|
|
|
|
|
global ord_pot_all_y
|
|
|
|
|
set ord_pot_all_x_old_format $ord_pot_all_x
|
|
|
|
|
set ord_pot_all_y_old_format $ord_pot_all_y
|
|
|
|
|
set ord_pot_all_x ""
|
|
|
|
|
set ord_pot_all_y ""
|
|
|
|
|
for { set ixy 0 } { $ixy <= 191 } { incr ixy } {
|
|
|
|
|
lappend ord_pot_all_x [lindex $ord_pot_all_y_old_format $ixy]
|
|
|
|
|
lappend ord_pot_all_y [lindex $ord_pot_all_x_old_format [expr 191 - $ixy]]
|
|
|
|
|
}
|
|
|
|
|
clientput " All pot settings reordered from 21000N format to normal format."
|
|
|
|
|
clientput "x settings:" $ord_pot_all_x
|
|
|
|
|
clientput "y settings:" $ord_pot_all_y
|
|
|
|
|
}
|
|
|
|
|
Publish ord_load_pot_all_old_format User
|
|
|
|
|
|
|
|
|
|
set histogram_xy ""
|
|
|
|
|
set histogram_x ""
|
|
|
|
|
set histogram_y ""
|
|
|
|
|
@@ -157,7 +205,7 @@ proc ord_get_histogram_xy { bs_x_l bs_x_h bs_y_l bs_y_h roi_x_l roi_x_h roi_y_l
|
|
|
|
|
global histogram_x
|
|
|
|
|
global histogram_y
|
|
|
|
|
clientput "Retrieving 2D xy histogram..."
|
|
|
|
|
set histogram_xy [ lreplace [ split [ hmm get 1 ] ] 0 1 ]
|
|
|
|
|
set histogram_xy [ lreplace [ split [ ::histogram_memory::gethmm HISTOPERIOD_XY ] ] 0 1 ]
|
|
|
|
|
if { ($bs_x_l > $bs_x_h || $bs_y_l > $bs_y_h) && $roi_x_l == 0 && $roi_x_h == 191 && $roi_y_l == 0 && $roi_y_h == 191 } {
|
|
|
|
|
set get_full_histogram 1
|
|
|
|
|
clientput "Calculating 2D histograms over full detector area..."
|
|
|
|
|
|