143 lines
4.4 KiB
Python
143 lines
4.4 KiB
Python
def count (count_time):
|
|
waitmove
|
|
count_em (count_time) # triggers the counting process
|
|
waitcount # waits for counting to finish
|
|
count_end # clean up after counting
|
|
get_counts # retrieve the counts from detectors
|
|
chk_xray # verify quality of xray
|
|
chk_counts # verify quality of counts
|
|
chk_beam # terminate this count loop
|
|
if (S[sec] && MON >= 0)
|
|
MON_RATE=S[MON]/S[sec]
|
|
|
|
|
|
|
|
|
|
def count_em (count_time):
|
|
# ========
|
|
while (mythen.is_acquiring()):
|
|
mythen.stop()
|
|
time.sleep(0.25)
|
|
|
|
user_precount()
|
|
|
|
if (count_time != 0):
|
|
if (count_time > 0):
|
|
# MYTHEN
|
|
mythen.set_acquire_time(count_time)
|
|
mythen.set_acquire_mode("Single")
|
|
mythen.start()
|
|
else:
|
|
print "Preset monitor counting is not supported\!"
|
|
user_postcount()
|
|
|
|
|
|
|
|
# define new count_end, chk_counts, and chk_xray macros:
|
|
def count_end 'user_count_end'
|
|
def chk_counts 'user_chk_counts'
|
|
def chk_xray 'user_chk_xray'
|
|
# use the EPICS DCR508 scaler
|
|
# initially, user_count_end, user_chk_counts, and user_chk_xray are empty:
|
|
def user_count_end '' # if used, this should be a chained macro definition
|
|
def user_chk_counts '' # if used, this should be a chained macro definition
|
|
def user_chk_xray '' # if used, this should be a chained macro definition
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# ct - second lowest level count command - for manual count.
|
|
# This version is slightly expanded with respect to
|
|
# the original definition in standard.mac:
|
|
# count_end has been added to provide further
|
|
# flexibility regarding the use of various detectors.
|
|
#
|
|
# Note: See also the description of the modified 'count' command for more
|
|
# information.
|
|
#-
|
|
|
|
def ct (count_time):
|
|
# ==
|
|
|
|
cdef("cleanup_once", "onp; show_cnts; offp; user_ct", "ct")
|
|
waitmove
|
|
count_em (count_time) # triggers the counting process
|
|
waitcount # waits for counting to finish
|
|
count_end # clean up after counting
|
|
cdef("cleanup_once", "", "ct", "delete")
|
|
onp; show_cnts; offp
|
|
user_ct
|
|
|
|
}'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# recount - allows to retake the last data point - useful when
|
|
# files (images) need to be overwritten. Include
|
|
# device-specific code in user_pre_recount and
|
|
# user_post_recount.
|
|
#
|
|
# Note: This is essentially a modified version of count
|
|
# without the check commands (chk_xray, chk_counts,
|
|
# and chk_beam) at the end.
|
|
#-
|
|
|
|
def recount '{
|
|
# =======
|
|
|
|
waitmove
|
|
user_pre_recount # should be a chained macro definition
|
|
count_em $1 # triggers the counting process
|
|
waitcount # waits for counting to finish
|
|
count_end # clean up after counting
|
|
get_counts # retrieve the counts from detectors
|
|
user_post_recount # should be a chained macro definition
|
|
}'
|
|
|
|
# initially, user_pre_recount and user_post_recount are empty.
|
|
def user_pre_recount ''
|
|
def user_post_recount ''
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# waitcount - waits for counting to stop
|
|
#-
|
|
|
|
def waitcount(count_time):
|
|
user_waitcount()
|
|
|
|
i = 0
|
|
while (mythen.is_acquiring()):
|
|
sleep (0.05)
|
|
i += 1
|
|
if (i * 0.05 >= count_time * 2):
|
|
print "MYTHEN Izero times out, status: " + str(mythen.get_status())
|
|
break
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# get_counts - lowest level counter reading macro.
|
|
#-
|
|
|
|
def get_counts():
|
|
# ==========
|
|
|
|
S[0] = mythen.get_acquire_time(readback=False)
|
|
S[1] = mythen.get_total_counts()
|
|
# S[2] is detector counts from image.mac
|
|
S[3] = S[2] / COUNT_TIME / epics_get("X04SA-ES2-FI:TRANSM")
|
|
|
|
S[5] = epics_get ("X04SA-ES2-FI:TRANSM")
|
|
|
|
COUNT_ID++ # increment the exposure ID
|
|
|
|
# set threshold counts in case auto-level support is available
|
|
if ((whatis("AUTO_THRESH1") & 0x08000000) == 0) {
|
|
AUTO_THRESH1_COUNT = (S[2]>=AUTO_THRESH1)?S[2]:0
|
|
AUTO_THRESH2_COUNT = (S[2]>=AUTO_THRESH2)?S[2]:0
|
|
AUTO_THRESH3_COUNT = (S[2]>=AUTO_THRESH3)?S[2]:0
|
|
AUTO_THRESH4_COUNT = (S[2]>=AUTO_THRESH4)?S[2]:0
|
|
}
|
|
|
|
user_getcounts
|
|
}'
|