|
@@ -4,6 +4,8 @@ import os
|
|
|
from .BaseClass import BaseClass
|
|
from .BaseClass import BaseClass
|
|
|
import settings
|
|
import settings
|
|
|
import time
|
|
import time
|
|
|
|
|
+from .capture.module_digicam import DigiCam
|
|
|
|
|
+from .capture.module_watch_dog import FileEventHandler
|
|
|
|
|
|
|
|
class ProgramItem(BaseClass):
|
|
class ProgramItem(BaseClass):
|
|
|
# program_sign = Signal(dict)
|
|
# program_sign = Signal(dict)
|
|
@@ -14,6 +16,10 @@ class ProgramItem(BaseClass):
|
|
|
# 1 表示等待中,2表示没有等待
|
|
# 1 表示等待中,2表示没有等待
|
|
|
self.wait_state = 2
|
|
self.wait_state = 2
|
|
|
self.data = action_data
|
|
self.data = action_data
|
|
|
|
|
+ self.capture_one = DigiCam()
|
|
|
|
|
+ captrure_folder_path = self.capture_one.getCaptureFolderPath()
|
|
|
|
|
+ self.watch_dog = FileEventHandler()
|
|
|
|
|
+ self.watch_dog.start_observer(captrure_folder_path)
|
|
|
print("21 =========ProgramItem=======action_data=====")
|
|
print("21 =========ProgramItem=======action_data=====")
|
|
|
print(action_data)
|
|
print(action_data)
|
|
|
self.action_id = self.get_value(action_data, "id")
|
|
self.action_id = self.get_value(action_data, "id")
|
|
@@ -229,15 +235,15 @@ class ProgramItem(BaseClass):
|
|
|
)
|
|
)
|
|
|
time.sleep(0.1)
|
|
time.sleep(0.1)
|
|
|
|
|
|
|
|
- if self.mcu.action_state != 1:
|
|
|
|
|
- # 外部终止,停止运行
|
|
|
|
|
- print("外部终止,停止运行")
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ # if self.mcu.action_state != 1:
|
|
|
|
|
+ # # 外部终止,停止运行
|
|
|
|
|
+ # print("外部终止,停止运行")
|
|
|
|
|
+ # return
|
|
|
|
|
|
|
|
- if self.mode_type != "其他配置":
|
|
|
|
|
|
|
+ # if self.mode_type != "其他配置":
|
|
|
# MCU运动是否有停止检查,设定超时时间
|
|
# MCU运动是否有停止检查,设定超时时间
|
|
|
- if self.check_mcu_move_is_stop() is False:
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ # if self.check_mcu_move_is_stop() is False:
|
|
|
|
|
+ # return
|
|
|
|
|
|
|
|
# print("{} 检查停止时间1:{}".format(self.action_name, time.time() - start_time))
|
|
# print("{} 检查停止时间1:{}".format(self.action_name, time.time() - start_time))
|
|
|
if self.is_led:
|
|
if self.is_led:
|
|
@@ -246,28 +252,28 @@ class ProgramItem(BaseClass):
|
|
|
self.mcu.to_deal_device(device_name="laser_position", value=0)
|
|
self.mcu.to_deal_device(device_name="laser_position", value=0)
|
|
|
|
|
|
|
|
if self.shoe_overturn:
|
|
if self.shoe_overturn:
|
|
|
- if self.mcu.action_state != 1:
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ # if self.mcu.action_state != 1:
|
|
|
|
|
+ # return
|
|
|
self.mcu.to_deal_device(device_name="overturn_steering")
|
|
self.mcu.to_deal_device(device_name="overturn_steering")
|
|
|
# time.sleep(0.1)
|
|
# time.sleep(0.1)
|
|
|
if self.camera_height is not None:
|
|
if self.camera_height is not None:
|
|
|
- if self.mcu.action_state != 1:
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ # if self.mcu.action_state != 1:
|
|
|
|
|
+ # return
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
device_name="camera_high_motor", value=self.camera_height
|
|
device_name="camera_high_motor", value=self.camera_height
|
|
|
)
|
|
)
|
|
|
# time.sleep(0.1)
|
|
# time.sleep(0.1)
|
|
|
if self.camera_angle is not None:
|
|
if self.camera_angle is not None:
|
|
|
- if self.mcu.action_state != 1:
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ # if self.mcu.action_state != 1:
|
|
|
|
|
+ # return
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
device_name="camera_steering", value=self.camera_angle
|
|
device_name="camera_steering", value=self.camera_angle
|
|
|
)
|
|
)
|
|
|
# time.sleep(0.1)
|
|
# time.sleep(0.1)
|
|
|
|
|
|
|
|
if self.turntable_position is not None:
|
|
if self.turntable_position is not None:
|
|
|
- if self.mcu.action_state != 1:
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ # if self.mcu.action_state != 1:
|
|
|
|
|
+ # return
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
device_name="turntable_position_motor",
|
|
device_name="turntable_position_motor",
|
|
|
value=self.turntable_position,
|
|
value=self.turntable_position,
|
|
@@ -275,21 +281,21 @@ class ProgramItem(BaseClass):
|
|
|
# time.sleep(0.1)
|
|
# time.sleep(0.1)
|
|
|
|
|
|
|
|
if self.turntable_angle is not None:
|
|
if self.turntable_angle is not None:
|
|
|
- if self.mcu.action_state != 1:
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ # if self.mcu.action_state != 1:
|
|
|
|
|
+ # return
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
device_name="turntable_steering", value=self.turntable_angle
|
|
device_name="turntable_steering", value=self.turntable_angle
|
|
|
)
|
|
)
|
|
|
# time.sleep(0.1)
|
|
# time.sleep(0.1)
|
|
|
|
|
|
|
|
# MCU运动是否有停止检查,设定超时时间
|
|
# MCU运动是否有停止检查,设定超时时间
|
|
|
- if self.mcu.action_state != 1:
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ # if self.mcu.action_state != 1:
|
|
|
|
|
+ # return
|
|
|
if self.mode_type != "其他配置":
|
|
if self.mode_type != "其他配置":
|
|
|
time.sleep(1.2)
|
|
time.sleep(1.2)
|
|
|
- if self.check_mcu_move_is_stop(re_check=True) is False:
|
|
|
|
|
- print("MCU检测运动未停止,自动退出, 提前退出")
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ # if self.check_mcu_move_is_stop(re_check=True) is False:
|
|
|
|
|
+ # print("MCU检测运动未停止,自动退出, 提前退出")
|
|
|
|
|
+ # return
|
|
|
# print("{} 检查停止时间2:{}".format(self.action_name, time.time() - start_time))
|
|
# print("{} 检查停止时间2:{}".format(self.action_name, time.time() - start_time))
|
|
|
|
|
|
|
|
if self.delay_time:
|
|
if self.delay_time:
|
|
@@ -306,8 +312,8 @@ class ProgramItem(BaseClass):
|
|
|
# except:
|
|
# except:
|
|
|
# pass
|
|
# pass
|
|
|
|
|
|
|
|
- if self.mcu.action_state != 1:
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ # if self.mcu.action_state != 1:
|
|
|
|
|
+ # return
|
|
|
# print("{} 检查停止时间4:{}".format(self.action_name, time.time() - start_time))
|
|
# print("{} 检查停止时间4:{}".format(self.action_name, time.time() - start_time))
|
|
|
# if self.is_wait:
|
|
# if self.is_wait:
|
|
|
# self.windows.playsound.tips_type = "wait"
|
|
# self.windows.playsound.tips_type = "wait"
|
|
@@ -318,9 +324,9 @@ class ProgramItem(BaseClass):
|
|
|
# self.windows.event.wait()
|
|
# self.windows.event.wait()
|
|
|
# self.windows.event.clear()
|
|
# self.windows.event.clear()
|
|
|
# self.wait_state = 2
|
|
# self.wait_state = 2
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
|
|
- # print("==={},中途退出".format(self.action_name))
|
|
|
|
|
- # return
|
|
|
|
|
|
|
+ # if self.mcu.action_state != 1:
|
|
|
|
|
+ # print("==={},中途退出".format(self.action_name))
|
|
|
|
|
+ # return
|
|
|
# self.next_step.hide()
|
|
# self.next_step.hide()
|
|
|
|
|
|
|
|
# print("self.is_photograph", self.is_photograph)
|
|
# print("self.is_photograph", self.is_photograph)
|
|
@@ -331,10 +337,10 @@ class ProgramItem(BaseClass):
|
|
|
# 用于临时拍照计数
|
|
# 用于临时拍照计数
|
|
|
# self.windows.add_goods_images_count(self.goods_art_no)
|
|
# self.windows.add_goods_images_count(self.goods_art_no)
|
|
|
|
|
|
|
|
- # if self.af_times > 0:
|
|
|
|
|
- # self.windows.capture_one.photograph(is_af=True)
|
|
|
|
|
- # else:
|
|
|
|
|
- # self.windows.capture_one.photograph(is_af=False)
|
|
|
|
|
|
|
+ if self.af_times > 0:
|
|
|
|
|
+ self.capture_one.photograph(is_af=True)
|
|
|
|
|
+ else:
|
|
|
|
|
+ self.capture_one.photograph(is_af=False)
|
|
|
|
|
|
|
|
self.last_photograph_time = time.time() # 记录最近一次拍照时间
|
|
self.last_photograph_time = time.time() # 记录最近一次拍照时间
|
|
|
|
|
|