From 6b37ae2b15eca92b3cacac0e113290eb28ccfa8b Mon Sep 17 00:00:00 2001
From: wu_xinjun <bent20140204@outlook.com>
Date: 星期一, 20 六月 2022 15:49:50 +0800
Subject: [PATCH] get pointclouds from client

---
 src/microwave/deviceTools.py |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/microwave/deviceTools.py b/src/microwave/deviceTools.py
index e57379a..01af872 100644
--- a/src/microwave/deviceTools.py
+++ b/src/microwave/deviceTools.py
@@ -6,8 +6,9 @@
 import open3d as o3d
 from multiprocessing import  Pool
 import numpy as np
+import threading
 
-from ..utils import file_fliter, write_ply
+from ..utils.tools import file_fliter, write_ply
 from .servers import MicroWaveReceiver,MicroWaveUDPThread
 from .parsers import MicroWaveParser
 
@@ -18,7 +19,7 @@
     # host = '192.168.2.65' # use this host to get the udp data from microwave device
     port = 9911
     udp_queue = queue.Queue()
-    udp_get_stop = {"value": False}
+    udp_get_stop = threading.Event()
 
     if subFolder is not None:
         path = os.path.join(saveFolder,subFolder)
@@ -48,9 +49,9 @@
 
         while run:
             packed_count = 0
-            while run or not udp_queue.empty():
+            while not udp_queue.empty():
                 value = udp_queue.get()
-                while value is not False:
+                if value is not False:
                     time_tag = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
                     with ('{}/{}_packet{}.udp'.format(path,time_tag,packed_count), 'wb') as f:
                         f.write(udp_queue.get())
@@ -59,11 +60,11 @@
                     run = False
 
     except KeyboardInterrupt:
-        udp_get_stop = {"value": True}
+        udp_get_stop.set()
         print(time.asctime(),"Server Stopped")
     except:
-        udp_get_stop = {"value": True}
-        print(time.asctime(),"Server Stopped")
+        udp_get_stop.set()
+        print(time.asctime(),"Server Stopped with unknown reasons")
 
 # udp2bin
 def udp2bin_tool(udp_folder_Or_list):
@@ -76,7 +77,7 @@
     else:
         UDPfolder = udp_folder_Or_list
         # example pod1-2022-02-21-13-25-03_packet125.udp --> 125
-        sort_lambda = lambda x:int(x.split('packet')[1][:-4])
+        sort_lambda = lambda x:int(x.split('packet')[-1][:-4])
         udp_files = file_fliter(UDPfolder,'udp', sort_lambda)
         Save = True
 

--
Gitblit v1.9.1