def set_bval(bval): print("BVAL: " + str(bval)) if (bval < 16): padb = '0' else: padb = '' ledserial.send(bytes.fromhex('0d ' + padb + hex(bval).split('x')[1]))
def set_gval(gval): print("GVAL: " + str(gval)) if (gval < 16): padg = '0' else: padg = '' ledserial.send(bytes.fromhex('0c ' + padg + hex(gval).split('x')[1]))
def __save_images(save_type): global __IMSHOW_DICT global __PD global __HIST_DICT pool = mp.Pool(mp.cpu_count()) if not __STREAM: raise RuntimeError( 'Stream has not been started yet! Please start it first.') if save_type == 'bulk': num_images = 100 name_format = __GUI_DICT['name_format_text'].text else: # Get name format, counter, and number of images name_format = __GUI_DICT['name_format_text'].text num_images = int(__GUI_DICT['num_images_text'].text) num_to_avg = int(__GUI_DICT['avg_images_text'].text) #time_btwn_frames = int(__GUI_DICT['time_images_text'].text) #frmrate=int(spincam.get_frame_rate()) directory = __GUI_DICT['directory_text'].text counter = 0 file_number = 1 #if (time_btwn_frames != 0): #num_to_avg = int( frmrate * time_btwn_frames) img_name = name_format.replace('{date}', str(datetime.date.today())) if directory: directory = directory + '\\' img_main = directory + img_name.replace(' ', '_').replace( '.', '_').replace(':', '') img_name = img_main + '.tiff' img_csv = img_main + '.csv' print('Experiment start: ' + str(datetime.datetime.now())) for i in range(num_images): if save_type == 'bulk': bval = int('64', 16) - i gval = i ledserial.send(bytes.fromhex('0d ' + hex(bval).split('x')[1])) ledserial.send(bytes.fromhex('0c ' + hex(gval).split('x')[1])) image_dict = spincam.get_image_and_avg(num_to_avg) # Make sure images are complete if 'data' in image_dict: # Save image try: #print('Acquired: ' + img_name) #ski.imsave(img_name, image_dict['data'].astype(np.uint16), compress=0, append=True) pool.apply_async(save_image, args=(img_name, image_dict), callback=collect_result) print('Finished Acquiring ' + img_name) #counter=counter+1 #if ( __PD == 1): # ledserial.send('s') # with open(img_csv,"a+") as p: # p.write(str(datetime.datetime.now()).split(" ")[1]+", "+str(ledserial.read_power()).split("'")[1].split("\\")[0]+"\n") # p.close() #if (counter == 10): # img_name= img_main + '_' + str(file_number) + '.tiff' # file_number = file_number + 1 # counter=0 except: print(sys.exc_info()[0]) print('Experiment end: ' + str(datetime.datetime.now()))
def __ledbg(_=None): ledserial.send(bytes.fromhex('0b00')) ledserial.send(bytes.fromhex('0c64')) ledserial.send(bytes.fromhex('0d64')) ledserial.send(bytes.fromhex('0e00'))
def __noled(_=None): ledserial.send(bytes.fromhex('0b00')) ledserial.send(bytes.fromhex('0c00')) ledserial.send(bytes.fromhex('0d00')) ledserial.send(bytes.fromhex('0e00'))
def __ledy(_=None): ledserial.send(bytes.fromhex('0b00')) ledserial.send(bytes.fromhex('0c00')) ledserial.send(bytes.fromhex('0d00')) ledserial.send(bytes.fromhex('0e64'))