diff --git a/script/device/Mythen.py b/script/device/Mythen.py index 861757a..cd0a382 100644 --- a/script/device/Mythen.py +++ b/script/device/Mythen.py @@ -59,4 +59,5 @@ class Mythen(DeviceBase, Readable): return self.get_total_counts() add_device( Mythen("mythen", "X04SA-ES2-SD1"), True) - +#mythen.polling = 1000 +mythen.update() diff --git a/script/local.py b/script/local.py index 122a7f3..a3ed3d1 100644 --- a/script/local.py +++ b/script/local.py @@ -27,4 +27,8 @@ def open_shutter(): def close_shutter(): """ """ - shutter.write("Off") \ No newline at end of file + shutter.write("Off") + + + +run("device/Mythen") \ No newline at end of file diff --git a/script/test/DetectorTriggering.py b/script/test/DetectorTriggering.py index 4f56a47..d632ad0 100644 --- a/script/test/DetectorTriggering.py +++ b/script/test/DetectorTriggering.py @@ -1,18 +1,37 @@ COUNT_ID = 0 + def count (count_time): - waitmove + #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 + waitcount (count_time) # 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] + if (S[sec] && MON >= 0): + MON_RATE=S[MON]/S[sec] +def ct (count_time): + #cdef("cleanup_once", "onp; show_cnts; offp; user_ct", "ct") #What means? showld do even if fail? + #waitmove + count_em (count_time) # triggers the counting process + waitcount (count_time) # waits for counting to finish + count_end() # clean up after counting + #cdef("cleanup_once", "", "ct", "delete") + onp; show_cnts; offp + +################ +#user_ct +################ + #end + global PIX_IS_ON + if ((PIX_IS_ON) && (pixconnected())): + print("image written to: /sls/X04SA/data/x04sa/ES3/pixel/images/%s%s%s\n" % (caget(PIX_PATHA_CHN), caget(PIX_PATHB_CHN), caget(PIX_FNAM_CHN))) + + def count_em (count_time): @@ -20,7 +39,17 @@ def count_em (count_time): mythen.stop() time.sleep(0.25) - user_precount() + ################ + #user_precount() + ################ + open_shutter() + #autoCalcExposure() TODO + global PIX_IS_ON + if ((PIX_IS_ON) && (pixconnected())): + pixsetexpose(count_time) + pixgetfilefmt() + pixsnap() + if (count_time != 0): if (count_time > 0): @@ -30,62 +59,58 @@ def count_em (count_time): mythen.start() else: print "Preset monitor counting is not supported\!" - user_postcount() - - - -def user_precount(): - open_shutter() - autoCalcExposure() - global PIX_IS_ON - if ((PIX_IS_ON) && (pixconnected())): - pixsetexpose(count_time) - pixgetfilefmt() - pixsnap() - - -def user_postcount(): + ################ + #user_postcount() + ################ pass -# 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. +# waitcount - waits for counting to stop #- -def ct (count_time): -# == +def waitcount(count_time): + if PIX_IS_ON: + pixwait() - 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 + i = 0 + while (mythen.is_acquiring()): + time.sleep (0.05) + i += 1 + if (i * 0.05 >= count_time * 2): + print "MYTHEN Izero times out, status: " + str(mythen.get_status()) + break -}' -#+ + + +def count_end(): + global PIX_IS_ON, PIX_LOG, IMAGE_FILENAME, COUNT_ID + + # update the IMAGE_FILENAME and COUNT_ID variables + if ((PIX_IS_ON) && (pixconnected())) { + IMAGE_FILENAME = sprintf("/sls/X04SA/data/x04sa/ES3/pixel/images/%s%s%s",\\ + epics_get(PIX_PATHA_CHN),\\ + epics_get(PIX_PATHB_CHN),\\ + epics_get(PIX_FNAM_CHN)) + COUNT_ID = epics_get(PIX_FNUM_CHN)-1 + } + + # write the image log if logging is enabled + if (PIX_IS_ON && (PIX_LOG != "")){ + pixlogwrite + } + + close_shutter() + + + + + + + +""" #------------------------------------------------------------------------------ # recount - allows to retake the last data point - useful when # files (images) need to be overwritten. Include @@ -97,9 +122,7 @@ def ct (count_time): # and chk_beam) at the end. #- -def recount '{ -# ======= - +def recount: waitmove user_pre_recount # should be a chained macro definition count_em $1 # triggers the counting process @@ -107,27 +130,28 @@ def recount '{ count_end # clean up after counting get_counts # retrieve the counts from detectors user_post_recount # should be a chained macro definition -}' + + +def user_pre_recount(): + pixUndo() +""" + + +def prescan_head(): + if (PIX_IS_ON) { + printf("\nfirst image will be: /sls/X04SA/data/x04sa/ES3/pixel/images/%s%s%s\n\n",\\ + epics_get(PIX_PATHA_CHN),\\ + epics_get(PIX_PATHB_CHN),\\ + sprintf(epics_get("X04SA-ES3-CCD:FNAM_FMT"),\\ + epics_get("X04SA-ES3-CCD:FNUM")+1)) + } + + # 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 #+ #------------------------------------------------------------------------------ @@ -144,11 +168,25 @@ def get_counts(count_time): COUNT_ID = COUNT_ID+1 # increment the exposure ID + #TODO:Auto + """ # set threshold counts in case auto-level support is available if "AUTO_THRESH1" in globals(): 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 + #TODO: image + #imageUserGetcounts() + + + + +def cleanup_always(): + close_shutter() + +def cleanup_once(): + tty_cntl("se") \ No newline at end of file