def unittest(): """ 模块单元测试 """ AllConfig.read_config_file() lidar = LidarHandle(AllConfig.host, AllConfig.port) lidar.connect() def print_queue(ar): while True: while not queue.empty(): print queue.get() print "" if ar[0] == 0: return time.sleep(0.2) # print queue.qsize() scan_flag = Array('i', 1) while True: scan_flag[0] = 1 scandata1_process = Process(target=lidar.open_scandata1, args=(scan_flag, )) scandata1_process.start() frame_process = Process(target=process_frame, args=(scan_flag, )) frame_process.start() # print_process = Process(target=print_queue, args=(scan_flag, )) # print_process.start() time.sleep(36000) lidar.close_scandata1(scan_flag) time.sleep(60)
def get_one_frame(): AllConfig.read_config_file() lidar = LidarHandle(AllConfig.host, AllConfig.port) lidar.connect() for i in range(0, 3): lidar.scandata() # f = open('one_frame.txt', 'w+') scan_flag = Array('i', 1) scan_flag[0] = 1 process_frame(scan_flag) while not queue.empty(): print queue.get() print ""
def system_poweron(): """ 初始化 """ AllConfig.read_config_file() Handle.connect() Handle.create_scan_process() print 'create_scan_process' Handle.create_read_process() print 'create_read_process' Handle.create_analysis_process() print 'create_analysis_process' ''' while not Handle.frame_queue.empty(): print Handle.frame_queue.get() print "" ''' time.sleep(3)
def record_lidar_frame(): """ 雷达帧保存到本地 """ AllConfig.read_config_file() lidar = LidarHandle(AllConfig.host, AllConfig.port) lidar.connect() frame_num = 15000 def print_queue(ar): while True: f_name = datetime.now().strftime("%Y%m%d%H%M%S") fp = gzip.open('out/' + f_name + '.txt.gz', 'wb') fp_cnt = 0 while fp_cnt < frame_num: while (not queue.empty()) and (fp_cnt < frame_num): if fp_cnt % 100 == 0: print "get_frame ", fp_cnt fp.write(queue.get()) fp.write('\n') fp_cnt += 1 if ar[0] == 0: fp.close() return if fp_cnt >= frame_num: print f_name, 'close' fp.close() break time.sleep(1) # print queue.qsize() scan_flag = Array('i', 1) scan_flag[0] = 1 scandata1_process = Process(target=lidar.open_scandata1, args=(scan_flag, )) scandata1_process.start() record_process = Process(target=print_queue, args=(scan_flag, )) record_process.start() time.sleep(3600) lidar.close_scandata1(scan_flag) time.sleep(3)
def frametest(): AllConfig.read_config_file() scan_flag = Array('i', 1) scan_flag[0] = 1 def txt2frame(): for frame in open('rec.txt'): queue.put(frame) time.sleep(1) # print queue.get() # return # 雷达驱动线程 scandata1_process = Process(target=txt2frame) scandata1_process.start() # tcp队列预处理线程 frame_process = Process(target=process_frame, args=(scan_flag, )) frame_process.start()
def main(): AllConfig.read_config_file() lidar = LidarHandle(AllConfig.host, AllConfig.port) lidar.connect() # print queue.qsize() scan_flag = Array('i', 1) scan_flag[0] = 1 # 雷达驱动线程 scandata1_process = Process(target=lidar.open_scandata1, args=(scan_flag, )) scandata1_process.start() # tcp队列预处理线程 frame_process = Process(target=process_frame, args=(scan_flag, )) frame_process.start() time.sleep(20) lidar.close_scandata1(scan_flag) print queue.qsize()