From fe9c6e6267d0adc9f6693f8f2f10cecba569bb65 Mon Sep 17 00:00:00 2001 From: dongchangxi <458593490@qq.com> Date: Sun, 29 Oct 2023 17:57:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9=EF=BC=8Cstep2=20=E5=92=8C=20step3?= =?UTF-8?q?=20=E4=B8=80=E8=B5=B7=E8=B7=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main_step2.py | 16 ++++++++++++++-- main_step3.py | 5 +++-- tools/auto_distance.py | 19 +++++++++++++++++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/main_step2.py b/main_step2.py index 2fcb68b..69c3f7b 100644 --- a/main_step2.py +++ b/main_step2.py @@ -41,8 +41,16 @@ def make3d(pid): print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 定位点导入完成') # defind_distance + #死循环阻塞获取 + while True: + time.sleep(3) + #判断是否有 pid_1 的的值 + if redisLocal.sismember('model:auto_distance', pid+"_1") == False: + continue + #如果存在就移除掉并退出死循环 + redisLocal.lrem('model:auto_distance', 0, pid+"_0") + break - time.sleep(35) shutil.move(os.path.join(config.workdir, pid, f'{pid}_wait.rcproj'), os.path.join(config.workdir, pid, f'{pid}.rcproj')) print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 定义定位点距离完成') #2023-10-27为了解决老版本使用step1 的 重建区域框的问题,这里加入了 -set "sfmEnableCameraPrior=True" -align -set "sfmEnableCameraPrior=False" align 使相机的对齐线统一向下后,再进行重建区域的设置 @@ -90,10 +98,14 @@ def step2(pid,task_distributed_id=""): if task_distributed_id == "": os.system(f'python d:\\make2\\main_step3.py {pid}') else: - main_service_db.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}) + #暂时 step2 step3 一起连续执行 + os.system(f'python d:\\make2\\main_step3.py {pid}') + main_service_db.update_task_distributed({"id":task_distributed_id,"status":2,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}) + #main_service_db.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}) return def main(pid): + redisLocal = config.redis_local if pid == '0': while True: # 取本地mysql队列任务,完成第二步的建模任务 diff --git a/main_step3.py b/main_step3.py index 033fe0a..5811368 100644 --- a/main_step3.py +++ b/main_step3.py @@ -209,8 +209,9 @@ def step3(pid,task_distributed_id=""): shutil.rmtree(os.path.join(config.workdir, pid), ignore_errors=True) libs_db.finish_task({"task_type": "make", "task_key": pid}) if task_distributed_id: - #更新子表的finished_at - main_service_db.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}) + #因为step2 和step3 是一起跑的,所以这一步先注释掉更新子表的finished_at + #main_service_db.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}) + #更新主表的status 和 finished_at main_service_db.update_task_distributed({"id":task_distributed_id,"status":2,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}) return diff --git a/tools/auto_distance.py b/tools/auto_distance.py index d709300..62d5af8 100644 --- a/tools/auto_distance.py +++ b/tools/auto_distance.py @@ -1,4 +1,4 @@ -import win32gui, win32con, time, os, sys +import win32gui, win32con, time, os, sys,redis import pyautogui as ag import platform if platform.system() == 'Windows': @@ -100,6 +100,7 @@ def get_defineDistances(pid, left, top, right, bottom): time.sleep(1.5) ag.press('enter') print(f'执行距离划定{index}') + @@ -122,9 +123,16 @@ def defind_distance(pid, left, top, right, bottom): ag.hotkey('ctrl', 's') # save project ag.hotkey('alt', 'f4') # close project print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} 定义定位点距离完成') - time.sleep(3) + + #更新 r.lpush('model:auto_distance', pid+"_0") + + #加入pid+"_1"的队列 + redisLocal.lpush('model:auto_distance', pid+"_1") + #去掉pid+"_0"的队列 + redisLocal.lrem('model:auto_distance', 0, pid+"_0") def main(): + redisLocal = config.redis_local while True: time.sleep(1) title = "wait" @@ -132,6 +140,13 @@ def main(): if pid == '0': pass else: + + #判断是否已经存在了,已经存在就不在处理了 + if redisLocal.sismember('model:auto_distance', pid+"_0") or redisLocal.sismember('model:auto_distance', pid+"_1"): + continue + + redisLocal.lpush('model:auto_distance', pid+"_0") + print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 找到{pid}的定位点距离定义窗口,开始定位点距离定义...') start_time = time.time() defind_distance(pid, left, top, right, bottom)