|
|
@@ -60,13 +60,12 @@ class ProgramItem(BaseClass):
|
|
|
# self.show()
|
|
|
|
|
|
def set_other(self):
|
|
|
- pass
|
|
|
- # if self.mode_type == "其他配置":
|
|
|
- # self.turntable_position = None
|
|
|
- # self.turntable_angle = None
|
|
|
- # self.delay_time = 0
|
|
|
- # self.after_delay_time = 0
|
|
|
- # self.is_led = False
|
|
|
+ if self.mode_type == "其他配置":
|
|
|
+ self.turntable_position = None
|
|
|
+ self.turntable_angle = None
|
|
|
+ self.delay_time = 0
|
|
|
+ self.after_delay_time = 0
|
|
|
+ self.is_led = False
|
|
|
|
|
|
def get_value(self, data, key, default=None):
|
|
|
if key not in data:
|
|
|
@@ -88,25 +87,12 @@ class ProgramItem(BaseClass):
|
|
|
if self.is_wait:
|
|
|
msg = "{}--等待".format(self.action_name)
|
|
|
self.sendSocketMessage(msg=msg,device_status=0)
|
|
|
- # self.ui_action_name.setText("{}--等待".format(self.action_name))
|
|
|
else:
|
|
|
msg = "{}".format(self.action_name)
|
|
|
self.sendSocketMessage(msg=msg, device_status=2)
|
|
|
- # self.ui_action_name.setText("{}".format(self.action_name))
|
|
|
-
|
|
|
- # self.next_step.hide()
|
|
|
tips_text = "程序:{},对焦:{}".format(1, 1)
|
|
|
- # msg = "{}".format(self.action_name)
|
|
|
self.sendSocketMessage(msg=tips_text, device_status=2)
|
|
|
- # self.ui_action_name.setToolTip(tips_text)
|
|
|
- # self.setStyleSheet("background-color: rgb(255, 235, 12);")
|
|
|
- # 执行单步命令
|
|
|
- # self.ui_retry.mousePressEvent = self.do_retry
|
|
|
- # self.next_step.mousePressEvent = self.next_step_clicked
|
|
|
self.set_state(state_value=0)
|
|
|
- # if settings.IS_TEST:
|
|
|
- # self.ui_retry.setText("单步")
|
|
|
- # self.ui_retry.setEnabled(True)
|
|
|
|
|
|
# def next_step_clicked(self, *args, **kwargs):
|
|
|
# self.windows.event.set()
|
|
|
@@ -135,17 +121,17 @@ class ProgramItem(BaseClass):
|
|
|
def check_mcu_move_is_stop(self, re_check=False):
|
|
|
self.error_info_text = ""
|
|
|
# 发送基础数据信息
|
|
|
- self.mcu.to_get_mcu_base_info()
|
|
|
+ # self.mcu.to_get_mcu_base_info()
|
|
|
_s = time.time()
|
|
|
last_num_1 = self.mcu.last_mcu_info_data["num"]
|
|
|
+ self.mcu.cleanAllReceiveData()
|
|
|
while 1:
|
|
|
- # if settings.IS_TEST:
|
|
|
- # time.sleep(2)
|
|
|
- # return True
|
|
|
if self.mcu.action_state != 1:
|
|
|
# 外部终止,停止运行
|
|
|
return False
|
|
|
- if time.time() - _s > 8:
|
|
|
+ cr_time = time.time()
|
|
|
+ print(cr_time - _s, cr_time,_s)
|
|
|
+ if cr_time - _s > 8:
|
|
|
self.error_info_text = "MCU检测运动未停止,自动退出"
|
|
|
self.set_state(state_value=99) # 标记异常
|
|
|
print("MCU检测运动未停止,自动退出")
|
|
|
@@ -154,24 +140,16 @@ class ProgramItem(BaseClass):
|
|
|
# return True
|
|
|
# 存在时间间隙,导致误认为所有设备已完成运动
|
|
|
if self.mcu.mcu_move_state == 2:
|
|
|
- # print("last_mcu_info_data 1", self.mcu.last_mcu_info_data["time"] - _s)
|
|
|
- if last_num_1 < self.mcu.last_mcu_info_data["num"]:
|
|
|
- # print("self.mcu.mcu_move_state", self.mcu.mcu_move_state)
|
|
|
- # print("运动时间:{}".format(time.time() - s))
|
|
|
- if re_check:
|
|
|
- last_num_2 = self.mcu.last_mcu_info_data["num"]
|
|
|
- self.mcu.to_get_mcu_base_info()
|
|
|
- time.sleep(0.5)
|
|
|
- # print("last_mcu_info_data 2", self.mcu.last_mcu_info_data["time"])
|
|
|
- # print("last_mcu_info_data 3", _t_2)
|
|
|
- if last_num_2 < self.mcu.last_mcu_info_data["num"]:
|
|
|
- if self.mcu.mcu_move_state == 2:
|
|
|
- return True
|
|
|
- else:
|
|
|
- return True
|
|
|
+ return True
|
|
|
+ else:
|
|
|
+ self.mcu.to_get_mcu_base_info()
|
|
|
+ self.mcu.send_all_cmd()
|
|
|
+ time.sleep(0.5)
|
|
|
+ self.mcu.get_basic_info_mcu()
|
|
|
+ # return True
|
|
|
|
|
|
time.sleep(0.1)
|
|
|
- self.mcu.to_get_mcu_base_info()
|
|
|
+ # self.mcu.to_get_mcu_base_info()
|
|
|
|
|
|
def run(self, total_len=5, *args):
|
|
|
if total_len == 1:
|
|
|
@@ -229,51 +207,30 @@ class ProgramItem(BaseClass):
|
|
|
start_time = time.time()
|
|
|
# ============连接MCU 处理步进电机与舵机等
|
|
|
if settings.IS_MCU:
|
|
|
- if settings.IS_LIN_SHI_TEST:
|
|
|
- self.mcu.to_deal_device(
|
|
|
- device_name="split", value=self.image_index
|
|
|
- )
|
|
|
- time.sleep(0.1)
|
|
|
-
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # # 外部终止,停止运行
|
|
|
- # print("外部终止,停止运行")
|
|
|
- # return
|
|
|
-
|
|
|
- # if self.mode_type != "其他配置":
|
|
|
+ if self.mode_type != "其他配置" and self.check_mcu_move_is_stop() is False:
|
|
|
# MCU运动是否有停止检查,设定超时时间
|
|
|
- # if self.check_mcu_move_is_stop() is False:
|
|
|
- # return
|
|
|
-
|
|
|
- # print("{} 检查停止时间1:{}".format(self.action_name, time.time() - start_time))
|
|
|
+ return
|
|
|
+ print("{} 检查停止时间1:{}".format(self.action_name, time.time() - start_time))
|
|
|
if self.is_led:
|
|
|
self.mcu.to_deal_device(device_name="laser_position", value=1)
|
|
|
else:
|
|
|
self.mcu.to_deal_device(device_name="laser_position", value=0)
|
|
|
|
|
|
if self.shoe_overturn:
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # return
|
|
|
self.mcu.to_deal_device(device_name="overturn_steering")
|
|
|
# time.sleep(0.1)
|
|
|
if self.camera_height is not None:
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # return
|
|
|
self.mcu.to_device_move(
|
|
|
device_name="camera_high_motor", value=self.camera_height
|
|
|
)
|
|
|
# time.sleep(0.1)
|
|
|
if self.camera_angle is not None:
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # return
|
|
|
self.mcu.to_device_move(
|
|
|
device_name="camera_steering", value=self.camera_angle
|
|
|
)
|
|
|
# time.sleep(0.1)
|
|
|
|
|
|
if self.turntable_position is not None:
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # return
|
|
|
self.mcu.to_device_move(
|
|
|
device_name="turntable_position_motor",
|
|
|
value=self.turntable_position,
|
|
|
@@ -281,103 +238,35 @@ class ProgramItem(BaseClass):
|
|
|
# time.sleep(0.1)
|
|
|
|
|
|
if self.turntable_angle is not None:
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # return
|
|
|
self.mcu.to_device_move(
|
|
|
device_name="turntable_steering", value=self.turntable_angle
|
|
|
)
|
|
|
# time.sleep(0.1)
|
|
|
|
|
|
# MCU运动是否有停止检查,设定超时时间
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # return
|
|
|
+ self.mcu.send_all_cmd()
|
|
|
if self.mode_type != "其他配置":
|
|
|
time.sleep(1.2)
|
|
|
- # 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("二次检查")
|
|
|
+ if self.check_mcu_move_is_stop(re_check=True) is False:
|
|
|
+ print("MCU检测运动未停止,自动退出, 提前退出")
|
|
|
+ return
|
|
|
|
|
|
if self.delay_time:
|
|
|
# print("拍照前延时:{}".format(self.delay_time))
|
|
|
time.sleep(self.delay_time)
|
|
|
- # print("{} 检查停止时间3:{}".format(self.action_name, time.time() - start_time))
|
|
|
- # if settings.CaptureSoftwareName == "capture_one":
|
|
|
- # if self.af_times > 0:
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # return
|
|
|
- # for i in range(int(self.af_times)):
|
|
|
- # try:
|
|
|
- # self.windows.capture_one.auto_focus()
|
|
|
- # except:
|
|
|
- # pass
|
|
|
-
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # return
|
|
|
- # print("{} 检查停止时间4:{}".format(self.action_name, time.time() - start_time))
|
|
|
- # if self.is_wait:
|
|
|
- # self.windows.playsound.tips_type = "wait"
|
|
|
- # self.windows.playsound.start()
|
|
|
- # self.next_step.show()
|
|
|
- # self.wait_state = 1
|
|
|
- # self.windows.event.clear()
|
|
|
- # self.windows.event.wait()
|
|
|
- # self.windows.event.clear()
|
|
|
- # self.wait_state = 2
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # print("==={},中途退出".format(self.action_name))
|
|
|
- # return
|
|
|
- # self.next_step.hide()
|
|
|
-
|
|
|
- # print("self.is_photograph", self.is_photograph)
|
|
|
|
|
|
if self.is_photograph:
|
|
|
+ print("拍照==>", time.time())
|
|
|
# print("photograph==================")
|
|
|
self.mcu.to_deal_device(device_name="buzzer", times=1)
|
|
|
# 用于临时拍照计数
|
|
|
- # self.windows.add_goods_images_count(self.goods_art_no)
|
|
|
-
|
|
|
- if self.af_times > 0:
|
|
|
- self.capture_one.photograph(is_af=True)
|
|
|
- else:
|
|
|
- self.capture_one.photograph(is_af=False)
|
|
|
-
|
|
|
+ is_af = True if self.af_times > 0 else False
|
|
|
+ self.capture_one.photograph(is_af=is_af)
|
|
|
self.last_photograph_time = time.time() # 记录最近一次拍照时间
|
|
|
-
|
|
|
- # 拍照后,进行等待确认
|
|
|
- # if settings.RUNNING_MODE == "待用户确认模式":
|
|
|
- # _f = False
|
|
|
- # if settings.RUNNING_MODE_DETAIL == "所有节点待确认":
|
|
|
- # _f = True
|
|
|
- # else:
|
|
|
- # if self.is_need_confirm:
|
|
|
- # _f = True
|
|
|
- # else:
|
|
|
- # _f = False
|
|
|
-
|
|
|
- # if _f:
|
|
|
- # # time.sleep(1.2)
|
|
|
- # # self.windows.playsound.tips_type = 'wait'
|
|
|
- # # self.windows.playsound.start()
|
|
|
- # # self.next_step.show()
|
|
|
- # self.wait_state = 1
|
|
|
- # # self.windows.event.clear()
|
|
|
- # # self.windows.event.wait()
|
|
|
- # # self.windows.event.clear()
|
|
|
- # self.wait_state = 2
|
|
|
- # if self.mcu.action_state != 1:
|
|
|
- # print("==={},中途退出".format(self.action_name))
|
|
|
- # return
|
|
|
- # self.next_step.hide()
|
|
|
-
|
|
|
# print("{} 拍照时间:{}".format(self.action_name, time.time() - start_time))
|
|
|
print("{}-{}已完成".format(self.action_type, self.action_name))
|
|
|
|
|
|
- # print("{} 检查停止时间5:{}".format(self.action_name, time.time() - start_time))
|
|
|
- # if settings.RUNNING_MODE == "普通模式":
|
|
|
- # if self.after_delay_time:
|
|
|
- # print("拍照后延时:{}".format(self.after_delay_time))
|
|
|
- # time.sleep(self.after_delay_time)
|
|
|
if True:
|
|
|
if self.after_delay_time:
|
|
|
print("拍照后延时:{}".format(self.after_delay_time))
|