Ver Fonte

停止拍摄

rambo há 7 meses atrás
pai
commit
5ba7dbdb3e

+ 8 - 0
python/api.py

@@ -155,6 +155,10 @@ def fromExcelHandler(params: HandlerDetail):
             image_dir = "{}/data/".format(os.getcwd()).replace("\\", "/")
             check_path(image_dir)
             for itemImg in images:
+                if itemImg.image_path == "" or itemImg.image_path == None:
+                    raise UnicornException(
+                        f"货号【{goods_art_no}】存在没有拍摄完成的图片,请重拍或删除后重试"
+                    )
                 if not os.path.exists(image_dir + "/" + os.path.basename(itemImg.image_path)):
                     shutil.copy(itemImg.image_path, image_dir)
             dealImage = DealImage(image_dir)
@@ -277,6 +281,10 @@ async def handle_detail(request: Request, params: HandlerDetail):
             image_dir = "{}/data/".format(os.getcwd()).replace("\\", "/")
             check_path(image_dir)
             for itemImg in images:
+                if itemImg.image_path == "" or itemImg.image_path == None:
+                    raise UnicornException(
+                        f"货号【{goods_art_no}】存在没有拍摄完成的图片,请重拍或删除后重试"
+                    )
                 if not os.path.exists(image_dir + "/" + os.path.basename(itemImg.image_path)):
                     shutil.copy(itemImg.image_path, image_dir)
             dealImage = DealImage(image_dir)

+ 12 - 0
python/docs/socket命令.md

@@ -520,4 +520,16 @@ _(该命令用于单独自定义配置中某一项的单独调整测试,不进
     "type": "re_take_picture"
 }
 ```
+#### 停止拍摄
+<mark>以下操作需要连接设备且初始化<mark>
+* data:null
+* type:
+    * 当该字段为stop_action时,代表停止拍摄
+##### 请求示例
+```python
+{
+    "data":null,
+    "type": "stop_action"
+}
+```
 ##### 未完待续.....

+ 4 - 0
python/mcu/DeviceControl.py

@@ -48,6 +48,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
         self.p_list = []
         self.temp_ports_dict = {}
         self.is_running = False
+        self.is_stop_action = False
         self.connect_state = False
         self.device_name_dict = {
             "camera_steering": 0,
@@ -1400,6 +1401,9 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
             self.msg_type = "mcu"
             for index, action in enumerate(config_list):
                 await asyncio.sleep(0.1)
+                if self.is_stop_action == True:
+                    self.is_stop_action = False
+                    break
                 action_is_take_picture = action["take_picture"]
                 image_index = -1
                 if action_is_take_picture:

+ 3 - 0
python/sockets/message_handler.py

@@ -63,6 +63,9 @@ async def handlerSend(
                 return
             device_ctrl = DeviceControl(websocket_manager=manager)
             device_ctrl.controlDevice(device_name, value)
+        case "stop_action":
+            device_ctrl = DeviceControl(websocket_manager=manager)
+            device_ctrl.is_stop_action = True
         case "run_mcu":
             msg_type = "run_mcu"
             # try: