def count_helper(fds): fds['count_fd'], fds['control_fd'] = counter.open_counter(args.tdc) count = counter.count(fds['control_fd'], fds['count_fd'], args.tdc) counter.close(fds['control_fd'], fds['count_fd']) if count!=None: return count else: return count_helper(fds)
INIT_DLY = 65 END_DLY = 70 FILENAME = 'dll_swp_5ps.csv' datalist = [] delay_fd = Gpib(name=DEVICE_NAME, pad=PRIMARY_ADDR) delay_fd.write("DLY {}".format(INIT_DLY)) time.sleep(3) start = time.clock() delay_fd.write("DLY {}".format(END_DLY)) for i in range(0, LOOPTILL): count_fd, control_fd = c.open_counter(INT_TIME) count = c.count(control_fd, count_fd, INT_TIME) datalist.append([count, time.clock() - start + 0.001 * (i + 1)]) c.close(control_fd, count_fd) #print('{},{}'.format(count,time.clock()-start)) print(time.clock() - start) save = open(FILENAME, 'w+') save.write('count, time\n') for data in datalist: out = '{}, {}\n'.format(data[0], data[1]) print out save.write(out) save.close()
import counter as c import time start = time.clock() for x in range(0, 100): count_fd, control_fd = c.open_counter(10) print c.count(control_fd, count_fd, 10) time.sleep(10.0 / 1000) c.close(control_fd, count_fd) print time.clock() - start