COUNT_ID = 0 def count (count_time): #waitmove() count_em (count_time) # triggers the counting process 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] 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): while (mythen.is_acquiring()): mythen.stop() time.sleep(0.25) ################ #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): # MYTHEN mythen.set_acquire_time(count_time) mythen.set_acquire_mode("Single") mythen.start() else: print "Preset monitor counting is not supported\!" ################ #user_postcount() ################ pass #------------------------------------------------------------------------------ # waitcount - waits for counting to stop #- def waitcount(count_time): if PIX_IS_ON: pixwait() 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 # 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 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 '' #+ #------------------------------------------------------------------------------ # get_counts - lowest level counter reading macro. #- def get_counts(count_time): global COUNT_ID S[0] = mythen.get_acquire_time(readback=False) S[1] = mythen.get_total_counts() # S[2] is detector counts from image.mac ###TOFO S[3] = S[2] / count_time / transm.getValue() S[5] = transm.getValue() 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")