|
@@ -12,20 +12,21 @@ import logging
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
+
|
|
|
class ProgramItem(BaseClass):
|
|
class ProgramItem(BaseClass):
|
|
|
# program_sign = Signal(dict)
|
|
# program_sign = Signal(dict)
|
|
|
# program_refresh_photo_list_sign = Signal()
|
|
# program_refresh_photo_list_sign = Signal()
|
|
|
|
|
|
|
|
def __init__(
|
|
def __init__(
|
|
|
- self,
|
|
|
|
|
- websocket_manager,
|
|
|
|
|
- action_data: any,
|
|
|
|
|
- mcu,
|
|
|
|
|
- goods_art_no: str = None,
|
|
|
|
|
- image_index: int = -1,
|
|
|
|
|
- record_id: int = -1,
|
|
|
|
|
- smart_shooter=None,
|
|
|
|
|
- is_get_mcu_state=True,
|
|
|
|
|
|
|
+ self,
|
|
|
|
|
+ websocket_manager,
|
|
|
|
|
+ action_data: any,
|
|
|
|
|
+ mcu,
|
|
|
|
|
+ goods_art_no: str = None,
|
|
|
|
|
+ image_index: int = -1,
|
|
|
|
|
+ record_id: int = -1,
|
|
|
|
|
+ smart_shooter=None,
|
|
|
|
|
+ is_get_mcu_state=True,
|
|
|
):
|
|
):
|
|
|
super().__init__(BaseClass)
|
|
super().__init__(BaseClass)
|
|
|
# 1 表示等待中,2表示没有等待
|
|
# 1 表示等待中,2表示没有等待
|
|
@@ -61,6 +62,8 @@ class ProgramItem(BaseClass):
|
|
|
self.camera_angle = float(self.get_value(action_data, "camera_angle", 0.0))
|
|
self.camera_angle = float(self.get_value(action_data, "camera_angle", 0.0))
|
|
|
self.af_times = self.get_value(action_data, "number_focus", 0)
|
|
self.af_times = self.get_value(action_data, "number_focus", 0)
|
|
|
self.shoe_overturn = self.get_value(action_data, "shoe_upturn", False)
|
|
self.shoe_overturn = self.get_value(action_data, "shoe_upturn", False)
|
|
|
|
|
+ # 焦段距离
|
|
|
|
|
+ self.camera_focal_distance = self.get_value(action_data, "camera_focal_distance", 1)
|
|
|
self.is_photograph = self.get_value(action_data, "take_picture", True)
|
|
self.is_photograph = self.get_value(action_data, "take_picture", True)
|
|
|
self.turntable_position = float(
|
|
self.turntable_position = float(
|
|
|
self.get_value(action_data, "turntable_position", 0.0)
|
|
self.get_value(action_data, "turntable_position", 0.0)
|
|
@@ -188,6 +191,7 @@ class ProgramItem(BaseClass):
|
|
|
print("\033[1;31m执行结束\033[0m", self.mcu.action_state)
|
|
print("\033[1;31m执行结束\033[0m", self.mcu.action_state)
|
|
|
# await asyncio.sleep(0.1)
|
|
# await asyncio.sleep(0.1)
|
|
|
# self.mcu.to_get_mcu_base_info()
|
|
# self.mcu.to_get_mcu_base_info()
|
|
|
|
|
+
|
|
|
async def _do_camera_check(self):
|
|
async def _do_camera_check(self):
|
|
|
"""执行一次完整的状态查询检测,返回是否全部停止"""
|
|
"""执行一次完整的状态查询检测,返回是否全部停止"""
|
|
|
self.mcu.send_get_all_info_to_mcu()
|
|
self.mcu.send_get_all_info_to_mcu()
|
|
@@ -227,6 +231,7 @@ class ProgramItem(BaseClass):
|
|
|
logger.info("拍照前运动检测状态[失败],耗时%.1f秒", time.time() - _s)
|
|
logger.info("拍照前运动检测状态[失败],耗时%.1f秒", time.time() - _s)
|
|
|
return False
|
|
return False
|
|
|
await asyncio.sleep(0.2)
|
|
await asyncio.sleep(0.2)
|
|
|
|
|
+
|
|
|
async def run(self, total_len=5, *args):
|
|
async def run(self, total_len=5, *args):
|
|
|
if total_len == 1:
|
|
if total_len == 1:
|
|
|
self.mode_type = "其他配置"
|
|
self.mode_type = "其他配置"
|
|
@@ -277,6 +282,8 @@ class ProgramItem(BaseClass):
|
|
|
device_name="turntable_steering", value=self.turntable_angle
|
|
device_name="turntable_steering", value=self.turntable_angle
|
|
|
)
|
|
)
|
|
|
time.sleep(0.1)
|
|
time.sleep(0.1)
|
|
|
|
|
+ if self.camera_focal_distance is not None:
|
|
|
|
|
+ self.mcu.to_device_move(device_name="camera_zoom_motor", value=self.camera_focal_distance)
|
|
|
loop = asyncio.get_event_loop()
|
|
loop = asyncio.get_event_loop()
|
|
|
# self.mcu.send_all_cmd()
|
|
# self.mcu.send_all_cmd()
|
|
|
loop.create_task(self.mcu.send_all_cmd())
|
|
loop.create_task(self.mcu.send_all_cmd())
|
|
@@ -287,7 +294,7 @@ class ProgramItem(BaseClass):
|
|
|
# return False
|
|
# return False
|
|
|
start_time = time.time()
|
|
start_time = time.time()
|
|
|
current_time = time.time()
|
|
current_time = time.time()
|
|
|
- self.mcu.is_get_mcu_state = self.is_get_mcu_state
|
|
|
|
|
|
|
+ self.mcu.is_get_mcu_state = self.is_get_mcu_state
|
|
|
# ============连接MCU 处理步进电机与舵机等
|
|
# ============连接MCU 处理步进电机与舵机等
|
|
|
if self.is_move_device:
|
|
if self.is_move_device:
|
|
|
if settings.IS_MCU:
|
|
if settings.IS_MCU:
|
|
@@ -307,8 +314,11 @@ class ProgramItem(BaseClass):
|
|
|
if self.shoe_overturn:
|
|
if self.shoe_overturn:
|
|
|
self.mcu.to_deal_device(device_name="overturn_steering")
|
|
self.mcu.to_deal_device(device_name="overturn_steering")
|
|
|
await asyncio.sleep(0.001)
|
|
await asyncio.sleep(0.001)
|
|
|
|
|
+ if self.camera_focal_distance is not None:
|
|
|
|
|
+ # 移动距离
|
|
|
|
|
+ self.mcu.to_device_move(device_name="camera_zoom_motor", value=self.camera_focal_distance)
|
|
|
if self.camera_height is not None:
|
|
if self.camera_height is not None:
|
|
|
- if (current_time - self.last_move_time)>110:
|
|
|
|
|
|
|
+ if (current_time - self.last_move_time) > 110:
|
|
|
if self.camera_height == 0:
|
|
if self.camera_height == 0:
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
device_name="camera_high_motor", value=1
|
|
device_name="camera_high_motor", value=1
|
|
@@ -319,10 +329,10 @@ class ProgramItem(BaseClass):
|
|
|
)
|
|
)
|
|
|
else:
|
|
else:
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
- device_name="camera_high_motor", value=self.camera_height-1
|
|
|
|
|
|
|
+ device_name="camera_high_motor", value=self.camera_height - 1
|
|
|
)
|
|
)
|
|
|
await asyncio.sleep(0.01)
|
|
await asyncio.sleep(0.01)
|
|
|
- logger.info("设备延迟执行===>,%s",time.time())
|
|
|
|
|
|
|
+ logger.info("设备延迟执行===>,%s", time.time())
|
|
|
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
|
|
|
)
|
|
)
|
|
@@ -333,17 +343,17 @@ class ProgramItem(BaseClass):
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
device_name="camera_steering", value=-39.9
|
|
device_name="camera_steering", value=-39.9
|
|
|
)
|
|
)
|
|
|
- logger.info("转盘位置首次运动===>,%s",-39.9)
|
|
|
|
|
|
|
+ logger.info("转盘位置首次运动===>,%s", -39.9)
|
|
|
elif self.turntable_position == 40:
|
|
elif self.turntable_position == 40:
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
device_name="camera_steering", value=39.9
|
|
device_name="camera_steering", value=39.9
|
|
|
)
|
|
)
|
|
|
- logger.info("转盘位置首次运动===>,%s",39.9)
|
|
|
|
|
|
|
+ logger.info("转盘位置首次运动===>,%s", 39.9)
|
|
|
else:
|
|
else:
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
- device_name="camera_steering", value=self.camera_angle-0.1
|
|
|
|
|
|
|
+ device_name="camera_steering", value=self.camera_angle - 0.1
|
|
|
)
|
|
)
|
|
|
- logger.info("转盘位置首次运动===>,%s",self.camera_angle-0.1)
|
|
|
|
|
|
|
+ logger.info("转盘位置首次运动===>,%s", self.camera_angle - 0.1)
|
|
|
await asyncio.sleep(0.01)
|
|
await asyncio.sleep(0.01)
|
|
|
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
|
|
@@ -353,25 +363,25 @@ class ProgramItem(BaseClass):
|
|
|
if self.turntable_position is not None:
|
|
if self.turntable_position is not None:
|
|
|
if self.turntable_position == 0:
|
|
if self.turntable_position == 0:
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
- device_name="turntable_position_motor", value=1
|
|
|
|
|
- )
|
|
|
|
|
- logger.info("转盘位置首次运动===>,%s",1)
|
|
|
|
|
|
|
+ device_name="turntable_position_motor", value=1
|
|
|
|
|
+ )
|
|
|
|
|
+ logger.info("转盘位置首次运动===>,%s", 1)
|
|
|
elif self.turntable_position == 800:
|
|
elif self.turntable_position == 800:
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
device_name="turntable_position_motor", value=799
|
|
device_name="turntable_position_motor", value=799
|
|
|
)
|
|
)
|
|
|
- logger.info("转盘位置首次运动===>,%s",799)
|
|
|
|
|
|
|
+ logger.info("转盘位置首次运动===>,%s", 799)
|
|
|
else:
|
|
else:
|
|
|
self.mcu.to_device_move(
|
|
self.mcu.to_device_move(
|
|
|
- device_name="turntable_position_motor", value=self.turntable_position-1
|
|
|
|
|
|
|
+ device_name="turntable_position_motor", value=self.turntable_position - 1
|
|
|
)
|
|
)
|
|
|
- logger.info("转盘位置首次运动===>,%s",self.turntable_position-1)
|
|
|
|
|
|
|
+ logger.info("转盘位置首次运动===>,%s", self.turntable_position - 1)
|
|
|
await asyncio.sleep(0.01)
|
|
await asyncio.sleep(0.01)
|
|
|
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,
|
|
|
)
|
|
)
|
|
|
- logger.info("转盘位置2次运动===>,%s",self.turntable_position)
|
|
|
|
|
|
|
+ logger.info("转盘位置2次运动===>,%s", self.turntable_position)
|
|
|
await asyncio.sleep(0.01)
|
|
await asyncio.sleep(0.01)
|
|
|
|
|
|
|
|
if self.turntable_angle is not None:
|
|
if self.turntable_angle is not None:
|
|
@@ -417,8 +427,8 @@ class ProgramItem(BaseClass):
|
|
|
"iso_config",
|
|
"iso_config",
|
|
|
None,
|
|
None,
|
|
|
)
|
|
)
|
|
|
- print(" camera_configs p_item",camera_configs)
|
|
|
|
|
- CameraKey = camera_configs[self.point_name].get("CameraKey",None)
|
|
|
|
|
|
|
+ print(" camera_configs p_item", camera_configs)
|
|
|
|
|
+ CameraKey = camera_configs[self.point_name].get("CameraKey", None)
|
|
|
print("smart shooter CameraShooter", record_id, goods_art_no, CameraKey)
|
|
print("smart shooter CameraShooter", record_id, goods_art_no, CameraKey)
|
|
|
await self.smart_shooter.CameraShooter(
|
|
await self.smart_shooter.CameraShooter(
|
|
|
msg_type="run_mcu",
|
|
msg_type="run_mcu",
|
|
@@ -440,7 +450,7 @@ class ProgramItem(BaseClass):
|
|
|
await asyncio.sleep(self.after_delay_time)
|
|
await asyncio.sleep(self.after_delay_time)
|
|
|
return True
|
|
return True
|
|
|
|
|
|
|
|
- async def RunSmartShooter(self, goods_art_no,record_id):
|
|
|
|
|
|
|
+ async def RunSmartShooter(self, goods_art_no, record_id):
|
|
|
await asyncio.gather(
|
|
await asyncio.gather(
|
|
|
self.smart_shooter.CameraShooter(
|
|
self.smart_shooter.CameraShooter(
|
|
|
msg_type="run_mcu",
|
|
msg_type="run_mcu",
|
|
@@ -448,6 +458,7 @@ class ProgramItem(BaseClass):
|
|
|
id=record_id,
|
|
id=record_id,
|
|
|
),
|
|
),
|
|
|
)
|
|
)
|
|
|
|
|
+
|
|
|
def digicam_take_picture(self):
|
|
def digicam_take_picture(self):
|
|
|
self.mcu.to_deal_device(device_name="buzzer", times=1)
|
|
self.mcu.to_deal_device(device_name="buzzer", times=1)
|
|
|
# 用于临时拍照计数
|
|
# 用于临时拍照计数
|
|
@@ -464,8 +475,8 @@ class ProgramItem(BaseClass):
|
|
|
4、重新触发进行拍照,并更新最近拍照时间
|
|
4、重新触发进行拍照,并更新最近拍照时间
|
|
|
"""
|
|
"""
|
|
|
if (
|
|
if (
|
|
|
- settings.getSysConfigs("other_configs", "running_mode", "普通模式")
|
|
|
|
|
- == "普通模式"
|
|
|
|
|
|
|
+ settings.getSysConfigs("other_configs", "running_mode", "普通模式")
|
|
|
|
|
+ == "普通模式"
|
|
|
):
|
|
):
|
|
|
return
|
|
return
|
|
|
|
|
|