From 1292adc7aafa34a7c93c80390826bdc5b6d05cbf Mon Sep 17 00:00:00 2001
From: wu_xinjun <bent20140204@outlook.com>
Date: 星期一, 27 六月 2022 17:14:06 +0800
Subject: [PATCH] add replay_to func for task
---
src/Server.py | 4 +++-
src/engine/MessageThreads.py | 49 +++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/src/Server.py b/src/Server.py
index 5818ae8..2416d9d 100644
--- a/src/Server.py
+++ b/src/Server.py
@@ -35,6 +35,7 @@
self.WEBport = WEBport
self.save_folder = save_folder
self.server_name = server_name
+ self.replay_host = "http://192.168.1.17:8001/admin/business/colletmeta/getDeviceMsg"
today = datetime.now().strftime('%Y-%m-%d')
today_folder = os.path.join(self.save_folder,today)
@@ -123,7 +124,8 @@
self.MsgDecoder_Thread = ths.decodeThread(
queue_list= queue_list,
queue_tags= queue_tags,
- task_folder= self.task_uuid_folder
+ task_folder= self.task_uuid_folder ,
+ replay_host=self.replay_host
)
self.MsgDecoder_Thread.setDaemon(True)
diff --git a/src/engine/MessageThreads.py b/src/engine/MessageThreads.py
index 8cc2344..d8cf0c2 100644
--- a/src/engine/MessageThreads.py
+++ b/src/engine/MessageThreads.py
@@ -7,6 +7,7 @@
from typing import List
import numpy as np
import cv2
+import requests
# # add python path of src to sys.path
# src_path = os.path.join(__file__, *(['..'] * 2))
@@ -151,13 +152,15 @@
def __init__(self,
queue_list:List[queue.Queue],
queue_tags:List[str],
- task_folder:dict[str,str]):
+ task_folder:dict[str,str],
+ replay_host:str):
super().__init__()
self.queue_list = queue_list
self.queue_tags = queue_tags
self.queue_num = 0
self.task_folder = task_folder
+ self.replay_host = replay_host
self.is_stop = False
assert len(self.queue_list) == len(self.queue_tags)
@@ -238,7 +241,12 @@
# display the info to the console
curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
- print(f"[x] {curr_time}|(From {msg_source}): {msg_context}" )
+ notice_str = f"[x] {curr_time}|(From {msg_source}): {msg_context}"
+ print(notice_str)
+ replay_to_(host = self.replay_host,
+ message=notice_str,
+ message_type="logs",
+ taskuuid=taskuuid)
# next msg
count += 1
@@ -282,7 +290,12 @@
# display the info to the console
curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
- print(f"[x] {curr_time}|(From {msg_source}): image{id} saved!" )
+ notice_str = f"[x] {curr_time}|(From {msg_source}): image{id} saved!"
+ print(notice_str)
+ replay_to_(host = self.replay_host,
+ message=notice_str,
+ message_type="images",
+ taskuuid=taskuuid)
# next image item
id += 1
@@ -330,6 +343,15 @@
filename = f"{msg_timestamp}-{msg_source}-pointcloud{id}"
write_ply(data_array,save_folder,filename)
+ # display the info to the console
+ curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
+ notice_str = f"[x] {curr_time}|(From {msg_source}): ply{id} saved!"
+ print(notice_str)
+ replay_to_(host = self.replay_host,
+ message=notice_str,
+ message_type="plys",
+ taskuuid=taskuuid)
+
# next ply item
id += 1
@@ -338,6 +360,25 @@
raise NotImplementedError("NOT IMPLEMENT!")
+
+def replay_to_(host:str,
+ message:str,
+ message_type:str,
+ taskuuid:str,
+ ):
+
+ if taskuuid != "init":
+ try:
+ # target = host+taskuuid
+ target = host
+ print(f"Send message to [{target}]")
+ payload = {"taskid":taskuuid, "messagetype":message_type, "message": message}
+ r = requests.post(target,params = payload,timeout=3)
+ print("send success!")
+ except Exception as e:
+ print(e)
+ print("send error!")
+ pass
def send_logs_tool(logs:List[str],
@@ -442,7 +483,7 @@
# end the outer while loop and triminate this function
else:
- print("[x] NO poindcloud has been captured!")
+ print("[x] NO pointcloud has been captured!")
run = False
else:
time.sleep(3)
--
Gitblit v1.9.1