You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.2 KiB
67 lines
2.2 KiB
from .utils.import_all_file import modify_file_dialog_path_and_import_all |
|
from .utils.click_soft_button import clickFileIMportShow, clickBegingSlice |
|
import time |
|
from .utils.oss_redis import redisClient |
|
from .utils.exe_operate import start_exe, click_confirm, close |
|
from .utils.logs import log |
|
import os |
|
from .utils.request import requestApiToUpdateSliceStatusComplate |
|
|
|
#"C:/test/10192_small_No4/data" |
|
def BeginSliceing(batchId,machineId, folderPath): |
|
# 打开3d切片软件 |
|
start_exe() |
|
time.sleep(1) |
|
#点击确认按钮 |
|
click_confirm() |
|
#先打开导入文件的弹框 |
|
clickFileIMportShow() |
|
time.sleep(1) |
|
#在输入路径导入obj文件 |
|
isSuccess = modify_file_dialog_path_and_import_all(folderPath) |
|
if not isSuccess: |
|
print("导入文件失败") |
|
exit() |
|
#点击开始切片 |
|
time.sleep(5) |
|
log("开始切片") |
|
clickBegingSlice() |
|
log("切片结束") |
|
time.sleep(5) |
|
#切片完成之后,将切片文件打包成zip文件,上传到OSS,并且请求api 更新批次状态为切片完成 |
|
requestApiToUpdateSliceStatusComplate(batchId, 0) |
|
# sadd 插入对应的队列 |
|
r = redisClient() |
|
r.sadd('pb:begin_print_machine_'+machineId, batchId) |
|
|
|
def main(work_dir=None): |
|
r = redisClient() |
|
while True: |
|
|
|
#判断队列连接是否正常,进行重连 |
|
if not r.ping(): |
|
log("队列连接异常,进行重连") |
|
r = redisClient() |
|
time.sleep(10) |
|
continue |
|
|
|
|
|
data = r.spop('pb:to_sliceing') |
|
if data is None: |
|
log("队列为空") |
|
time.sleep(10) |
|
continue |
|
data = data.decode('utf-8') |
|
# 判断是否是字符串 |
|
if not isinstance(data, str): |
|
log("取出的数据不是字符串") |
|
time.sleep(10) |
|
continue |
|
folderPath = os.path.join(work_dir, data) |
|
# data 格式为 batchId_machineType_No machineId |
|
batchId = data.split('_')[0] #批次ID |
|
# machineType = data.split('_')[1] #机型类型 |
|
machineId = data.split('_')[2].replace('No', '') #机器ID |
|
BeginSliceing(batchId,machineId,folderPath) |
|
time.sleep(10) |
|
|
|
|