def process_input(command_string): if (command_string == ""): return if (command_string == "q"): sys.exit() daq_lib.broadcast_output(time.ctime(time.time()) + "\n" + command_string) try: daq_lib.set_field("program_state","Program Busy") execute_command(command_string) except NameError as e: error_string = "Unknown command in queue: %s Error: %s" % (command_string, e) logger.error(error_string) exc_type, exc_value, exc_traceback = sys.exc_info() print("*** print_tb:") traceback.print_tb(exc_traceback, limit=1, file=sys.stdout) except SyntaxError: logger.error("Syntax error") except KeyError as e: logger.error("Key error. Error: %s. Command was: %s" % (e, command_string)) except TypeError as e: logger.error("Type error. Error: %s" % e) except AttributeError as e: logger.error("Attribute Error: %s" % e) except KeyboardInterrupt: abort_data_collection() logger.info("Interrupt caught by daq server\n") if (command_string != "pause_data_collection()" and command_string != "continue_data_collection()" and command_string != "abort_data_collection()" and command_string != "unmount_after_abort()" and command_string != "no_unmount_after_abort()"): daq_lib.set_field("program_state","Program Ready")
def print_status_thread(frequency): global count_list, ring_intensity previous_image_started = 0 percent_done = 0 shutter_dead_time = .6 while 1: time.sleep(frequency) current_percent_done = daq_lib.get_field("state_percent") if (daq_lib.image_started > 0): if (start_time == 0 or daq_lib.image_started != previous_image_started): previous_image_started = daq_lib.image_started start_time = time.time() now = time.time() total_time = float(daq_lib.image_started) if (total_time > 0.0): percent_done = int(.5 + ((now - start_time) / total_time * 100)) else: percent_done = 0 else: start_time = 0 percent_done = 0 if (percent_done != current_percent_done): daq_lib.set_field("state_percent", percent_done)
def process_input(command_string): if command_string == "": return # daq_utils.broadcast_output(time.ctime(time.time())) if command_string == "q": sys.exit() daq_lib.broadcast_output(time.ctime(time.time()) + "\n" + command_string) try: daq_lib.set_field("program_state", "Program Busy") execute_command(command_string) except NameError: error_string = "Unknown command: " + command_string print error_string except SyntaxError: print "Syntax error" except KeyError: print "Key error" except TypeError: print "Type error" except KeyboardInterrupt: abort_data_collection() print "Interrupt caught by daq server\n" if ( command_string != "pause_data_collection()" and command_string != "continue_data_collection()" and command_string != "abort_data_collection()" and command_string != "unmount_after_abort()" and command_string != "no_unmount_after_abort()" ): daq_lib.set_field("program_state", "Program Ready")
def read_intensity(time_to_count): global CNT local_count = [] # CNT = beamline_support.get_counts(time_to_count) local_count = beamline_support.get_counts(time_to_count) #index0=timer,1=chan2,... for i in xrange(1,number_of_counter_readouts+1): CNT[i] = local_count[i-1] update_s = "channel %d: %d" % (i,CNT[i]) daq_utils.broadcast_output(update_s) if (daq_lib.ringfile == "wire"): current = daq_utils.ring_current_from_wire(CNT[6],beamline_support.get_count_time()) else: current = daq_utils.ring_current() if (beamline_support.get_count_time() > 0 and current > 0): daq_lib.set_field("beamline_merit",int((CNT[2]/beamline_support.get_count_time())/current)) else: daq_lib.set_field("beamline_merit",0)
def ri_actual(time_to_count): global CNT local_count = [] local_count = beamline_support.get_counts( beamline_support.get_count_time()) #index0=timer,1=chan2,... for i in range(1, number_of_counter_readouts + 1): CNT[i] = local_count[i - 1] update_s = "channel %d: %d" % (i, CNT[i]) daq_utils.broadcast_output(update_s) if (daq_lib.ringfile == "wire"): current = daq_utils.ring_current_from_wire( CNT[6], beamline_support.get_count_time()) else: current = daq_utils.ring_current() if (beamline_support.get_count_time() > 0 and current > 0): daq_lib.set_field( "beamline_merit", int((CNT[2] / beamline_support.get_count_time()) / current)) else: daq_lib.set_field("beamline_merit", 0)
def print_status_thread(frequency): global count_list, ring_intensity previous_image_started = 0 percent_done = 0 shutter_dead_time = 0.6 while 1: time.sleep(frequency) current_percent_done = daq_lib.get_field("state_percent") if daq_lib.image_started > 0: if start_time == 0 or daq_lib.image_started != previous_image_started: previous_image_started = daq_lib.image_started start_time = time.time() now = time.time() total_time = float(daq_lib.image_started) if total_time > 0.0: percent_done = int(0.5 + ((now - start_time) / total_time * 100)) else: percent_done = 0 else: start_time = 0 percent_done = 0 if percent_done != current_percent_done: daq_lib.set_field("state_percent", percent_done)