소스 검색

分布执行

rambo 8 달 전
부모
커밋
76b785cb22
5개의 변경된 파일670개의 추가작업 그리고 2개의 파일을 삭제
  1. 125 0
      python/action.json
  2. 34 2
      python/mcu/DeviceControl.py
  3. 498 0
      python/mcu/ProgramItem.py
  4. 3 0
      python/settings.py
  5. 10 0
      python/sockets/message_handler.py

+ 125 - 0
python/action.json

@@ -0,0 +1,125 @@
+{
+    "type": "left",
+    "actions": [
+        {
+            "id": 2,
+            "mode_type": "执行左脚程序",
+            "execution_type": "程序1",
+            "action_name": "侧视图",
+            "action_index": 10,
+            "picture_index": 99,
+            "camera_height": 0,
+            "camera_angle": 3.0,
+            "number_focus": 0,
+            "take_picture": true,
+            "turntable_position": 300.0,
+            "turntable_angle": 0.0,
+            "shoe_upturn": false,
+            "pre_delay": 0.0,
+            "after_delay": 0.0,
+            "led_switch": false,
+            "is_wait": false,
+            "is_need_confirm": false
+        },
+        {
+            "id": 1,
+            "mode_type": "执行左脚程序",
+            "execution_type": "程序1",
+            "action_name": "左脚俯拍鞋子",
+            "action_index": 20,
+            "picture_index": 99,
+            "camera_height": 200,
+            "camera_angle": 14.0,
+            "number_focus": 2,
+            "take_picture": true,
+            "turntable_position": 300.0,
+            "turntable_angle": -32.0,
+            "shoe_upturn": false,
+            "pre_delay": 1.0,
+            "after_delay": 0.0,
+            "led_switch": false,
+            "is_wait": false,
+            "is_need_confirm": false
+        },
+        {
+            "id": 3,
+            "mode_type": "执行左脚程序",
+            "execution_type": "程序1",
+            "action_name": "拍后跟",
+            "action_index": 30,
+            "picture_index": 99,
+            "camera_height": 0,
+            "camera_angle": 3.0,
+            "number_focus": 0,
+            "take_picture": true,
+            "turntable_position": 450.0,
+            "turntable_angle": 70.0,
+            "shoe_upturn": false,
+            "pre_delay": 0.0,
+            "after_delay": 0.0,
+            "led_switch": false,
+            "is_wait": false,
+            "is_need_confirm": false
+        },
+        {
+            "id": 4,
+            "mode_type": "执行左脚程序",
+            "execution_type": "程序2",
+            "action_name": "拍鞋底",
+            "action_index": 40,
+            "picture_index": 99,
+            "camera_height": 0,
+            "camera_angle": 3.0,
+            "number_focus": 0,
+            "take_picture": true,
+            "turntable_position": 100.0,
+            "turntable_angle": 0.0,
+            "shoe_upturn": true,
+            "pre_delay": 3.0,
+            "after_delay": 0.0,
+            "led_switch": false,
+            "is_wait": false,
+            "is_need_confirm": false
+        },
+        {
+            "id": 5,
+            "mode_type": "执行左脚程序",
+            "execution_type": "程序2",
+            "action_name": "拍内里",
+            "action_index": 50,
+            "picture_index": 99,
+            "camera_height": 0,
+            "camera_angle": 3.0,
+            "number_focus": 0,
+            "take_picture": true,
+            "turntable_position": 500.0,
+            "turntable_angle": 180.0,
+            "shoe_upturn": false,
+            "pre_delay": 0.0,
+            "after_delay": 1.0,
+            "led_switch": false,
+            "is_wait": false,
+            "is_need_confirm": false
+        },
+        {
+            "id": 6,
+            "mode_type": "执行左脚程序",
+            "execution_type": "程序2",
+            "action_name": "初始化位置",
+            "action_index": 60,
+            "picture_index": 99,
+            "camera_height": 200,
+            "camera_angle": 12.0,
+            "number_focus": 1,
+            "take_picture": false,
+            "turntable_position": 300.0,
+            "turntable_angle": 0.0,
+            "shoe_upturn": false,
+            "pre_delay": 0.0,
+            "after_delay": 0.0,
+            "led_switch": true,
+            "is_wait": false,
+            "is_need_confirm": false
+        }
+    ]
+}

+ 34 - 2
python/mcu/DeviceControl.py

@@ -8,7 +8,7 @@ from sockets import ConnectionManager
 from collections import defaultdict
 import threading
 import settings
-
+from .ProgramItem import ProgramItem
 
 # mcu命令
 class DeviceControl(BaseClass, metaclass=SingletonType):
@@ -18,6 +18,8 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
         super().__init__(websocket_manager)
         self.msg_type = "mcu"
         self.m_t = 1
+        # 0未开始  1进行中 2已结束  99异常
+        self.action_state = 1
         self._mcu_move_state = 0
         self.state_camera_motor = 3
         self.state_camera_steering = 3
@@ -568,7 +570,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
                     "state_move_turntable_steering": self.state_move_turntable_steering,
                 },
             }
-            # if self.state_camera_motor 
+            # if self.state_camera_motor
             if all(value == 2 for value in [self.state_camera_motor, self.state_camera_steering, self.state_turntable_steering, self.state_overturn_steering]):
                 self.init_state = True
             self.sendSocketMessage(msg="获取mcu设备运行状态信息", data=message)
@@ -990,6 +992,26 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
         ]
         self.add_send_data_queue(data)
 
+    def to_get_mcu_base_info(self):
+        if self.connect_state:
+            self.lock.acquire()
+            # print('==========================>1111')
+            # print("-------------------to_get_mcu_base_info--------------------------")
+            data = [self.command["get_all_info"], 1]
+            f = True
+            try:
+                self.serial_ins.write_cmd(data)
+            except:
+                f = False
+                pass
+
+            self.lock.release()
+            if not f:
+                self.connect_state = False
+                return False
+            else:
+                return True
+
     def controlDevice(self, device_name, value):
         '''控制设备移动等'''
         if not self.is_running:
@@ -1059,6 +1081,16 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
             # case "photograph":
             #     self.photograph(goods_art_no=None)
 
+    def run_mcu_config(self,config_list,goods_art_no):
+        if config_list:
+            config_data = config_list[-1]
+            program_item = ProgramItem(
+                websocket_manager=self.websocket_manager,
+                action_data=config_data, mcu=self, goods_art_no=goods_art_no
+            )
+
+            program_item.run_only_mcu()
+
 
 async def checkMcuConnection(device_ctrl: DeviceControl):
     if device_ctrl.is_running == True:

+ 498 - 0
python/mcu/ProgramItem.py

@@ -0,0 +1,498 @@
+import json
+import os
+
+from .BaseClass import BaseClass
+import settings
+import time
+
+class ProgramItem(BaseClass):
+    # program_sign = Signal(dict)
+    # program_refresh_photo_list_sign = Signal()
+
+    def __init__(self,websocket_manager, action_data:any, mcu, goods_art_no:str=None):
+        super().__init__(BaseClass)
+        # 1 表示等待中,2表示没有等待
+        self.wait_state = 2
+        self.data = action_data
+        print("21 =========ProgramItem=======action_data=====")
+        print(action_data)
+        self.action_id = self.get_value(action_data, "id")
+        self.mode_type = self.get_value(action_data, "mode_type")
+        self.action_type = self.get_value(action_data, "execution_type", "程序1")
+        self.action_name = self.get_value(action_data, "action_name", "")
+        self.is_wait = self.get_value(action_data, "is_wait", False)
+        self.is_need_confirm = self.get_value(action_data, "is_need_confirm", False)
+        self.image_index = self.get_value(action_data, "picture_index", 99)
+        self.camera_height = self.get_value(action_data, "camera_height", 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.shoe_overturn = self.get_value(action_data, "shoe_upturn", False)
+        self.is_photograph = self.get_value(action_data, "take_picture", True)
+        self.turntable_position = float(
+            self.get_value(action_data, "turntable_position", 0.0)
+        )
+        self.turntable_angle = float(
+            self.get_value(action_data, "turntable_angle", 0.0)
+        )
+        self.delay_time = self.get_value(action_data, "pre_delay", 0.0)
+        self.after_delay_time = self.get_value(action_data, "after_delay", 0.0)
+        self.is_led = self.get_value(action_data, "led_switch", False)
+
+        self.last_photograph_time = None  # 最近一次拍照时间
+        self.goods_art_no = goods_art_no  # 货号
+
+        self.set_other()
+        self.error_info_text = ""  # 错误提示信息
+
+        # self.setParent(parent)
+        self.mcu = mcu
+
+        # if is_show:
+        #     self.parent = parent
+        #     self.setupUi(self)
+        #     self.init()
+        #     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
+
+    def get_value(self, data, key, default=None):
+        if key not in data:
+            data[key] = default
+            return default
+        return data[key]
+
+    def reset(self):
+        self.set_state(state_value=0)
+        self.error_info_text = ""  # 错误提示信息
+
+    def init(self):
+        self.icon_dict = {
+            0: "resources/other_icon/0weikaishi.png",
+            1: "resources/other_icon/1jinxingzhong.png",
+            2: "resources/other_icon/2yijieshu.png",
+            99: "resources/other_icon/11yichang.png",
+        }
+        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()
+
+    def set_state(self, state_value):
+        self.state = state_value
+        # icon = QPixmap(self.icon_dict[self.state])
+        # icon = icon.scaled(
+        #     self.ui_icon.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation
+        # )
+        # self.ui_icon.setPixmap(icon)
+        # if self.state == 0:
+        #     self.ui_retry.setText("")
+        #     self.ui_retry.setEnabled(False)
+        # if self.state == 1:
+        #     self.ui_retry.setText("")
+        #     self.ui_retry.setEnabled(False)
+        # if self.state == 2:
+        #     self.ui_retry.setText("单步")
+        #     self.ui_retry.setEnabled(True)
+        # if self.state == 99:
+        #     self.ui_retry.setText("重试")
+        #     self.ui_retry.setEnabled(True)
+        #     self.ui_action_name.setToolTip(self.error_info_text)
+
+    def check_mcu_move_is_stop(self, re_check=False):
+        self.error_info_text = ""
+        # 发送基础数据信息
+        self.mcu.to_get_mcu_base_info()
+        _s = time.time()
+        last_num_1 = self.mcu.last_mcu_info_data["num"]
+        while 1:
+            # if settings.IS_TEST:
+            #     time.sleep(2)
+            #     return True
+            if self.mcu.action_state != 1:
+                # 外部终止,停止运行
+                return False
+            if time.time() - _s > 8:
+                self.error_info_text = "MCU检测运动未停止,自动退出"
+                self.set_state(state_value=99)  # 标记异常
+                print("MCU检测运动未停止,自动退出")
+                self.sendSocketMessage(msg=self.error_info_text,device_status=-1)
+                return False
+                # 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
+
+            time.sleep(0.1)
+            self.mcu.to_get_mcu_base_info()
+
+    def run(self, total_len=5, *args):
+        if total_len == 1:
+            self.mode_type = "其他配置"
+            self.set_other()
+
+        print("1{}  - is run".format(self.action_name))
+        self.set_state(state_value=1)
+        if settings.IS_TEST:
+            self.do_run()
+        else:
+            try:
+                self.do_run()
+            except BaseException as e:
+                # print("p_item 错误:{}".format(e))
+                self.sendSocketMessage(
+                    msg="p_item 错误:{}".format(e), device_status=-1
+                )
+                self.set_state(state_value=99)
+
+        self.set_state(state_value=2)
+        return True
+
+    def run_only_mcu(self, *args):
+        # ============连接MCU 处理步进电机与舵机等
+        if settings.IS_MCU:
+            if self.shoe_overturn:
+                self.mcu.to_deal_device(device_name="overturn_steering")
+                time.sleep(0.1)
+            if self.camera_height is not None:
+                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:
+                self.mcu.to_device_move(
+                    device_name="camera_steering", value=self.camera_angle
+                )
+                time.sleep(0.1)
+            if self.turntable_position is not None:
+                self.mcu.to_device_move(
+                    device_name="turntable_position_motor",
+                    value=self.turntable_position,
+                )
+                time.sleep(0.1)
+            if self.turntable_angle is not None:
+                self.mcu.to_device_move(
+                    device_name="turntable_steering", value=self.turntable_angle
+                )
+                time.sleep(0.1)
+
+    def do_run(self, *args):
+        if not self.goods_art_no:  # and self.action_name != "初始化位置"
+            return False
+        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 != "其他配置":
+                # MCU运动是否有停止检查,设定超时时间
+                if self.check_mcu_move_is_stop() is False:
+                    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,
+                )
+                # 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
+            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))
+
+        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("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.windows.capture_one.photograph(is_af=True)
+            # else:
+            #     self.windows.capture_one.photograph(is_af=False)
+
+            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))
+                time.sleep(self.after_delay_time)
+        return True
+
+    def rephotograph_one_pic(self, *args):
+        """
+        1、获取最近一张照片
+        2、判断拍照时间距离当前节点的最近拍照时间是否小于3秒
+        3、删除该照片
+        4、重新触发进行拍照,并更新最近拍照时间
+        """
+        if settings.RUNNING_MODE == "普通模式":
+            return
+
+        print("-----100-2--self", self)
+        # 需要删除最近一张照片
+        # if self.last_photograph_time is not None:
+        #     record = self.windows.image_process_data.photo_todo_list
+        #     if record:
+        #         last_record = record[-1]
+        #         if self.goods_art_no == last_record["goods_art_no"]:
+        #             if last_record["is_photo"]:
+        #                 photo_create_time_formate = last_record[
+        #                     "photo_create_time_formate"
+        #                 ]
+        #                 image_path = last_record["image_path"]
+        #                 print(
+        #                     "photo_create_time_formate,self.last_photograph_time",
+        #                     photo_create_time_formate,
+        #                     self.last_photograph_time,
+        #                 )
+        #                 # 如果照片的时间大于触发时间,且小于3秒,则认定是当前触发
+        #                 if (
+        #                     self.last_photograph_time
+        #                     < photo_create_time_formate
+        #                     < self.last_photograph_time
+        #                     + settings.PHOTO_TRANSFER_TIME_INTERVAL
+        #                 ):
+        #                     if os.path.exists(image_path):
+        #                         os.remove(image_path)
+        #                         self.windows.add_goods_images_count(
+        #                             self.goods_art_no, flag=False
+        #                         )
+        #                         if (
+        #                             self.windows.image_process_data.goods_art_no_times_record
+        #                         ):
+        #                             goods_art_no = self.windows.image_process_data.goods_art_no_times_record[
+        #                                 0
+        #                             ][
+        #                                 "goods_art_no"
+        #                             ]
+        #                             if goods_art_no == self.goods_art_no:
+        #                                 self.windows.image_process_data.goods_art_no_times_record[
+        #                                     0
+        #                                 ][
+        #                                     "number"
+        #                                 ] -= 1
+        #                         self.program_refresh_photo_list_sign.emit()
+
+        # if self.is_photograph:
+        #     # 重新拍照
+        #     self.last_photograph_time = time.time()  # 记录最近一次拍照时间
+        #     print("last_photograph_time:", self.last_photograph_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.windows.capture_one.photograph(is_af=True)
+        #     else:
+        #         self.windows.capture_one.photograph(is_af=False)
+
+    def do_retry(self, *args, **kwargs):
+        """
+        重试操作,注意事项:
+        1、需要根据当前系统的角度位置,重新进行返回并拍摄
+        :param args:
+        :param kwargs:
+        :return:
+        """
+        # self.program_sign.emit({})
+        # print("do_retry")
+        self.reset()
+        self.mcu.action_state = 1
+        self.run()
+        self.mcu.action_state = 2
+
+    def get_photo_node_name_and_sound(self, photo_take_time):
+        data = {
+            "action_name": self.action_name,
+            "flag": False,
+            "is_sound_play": False,
+        }
+        if self.state == 0:
+            return data
+        if self.last_photograph_time is None:
+            return data
+        # if (
+        #     self.last_photograph_time
+        #     < photo_take_time
+        #     < self.last_photograph_time + settings.PHOTO_TRANSFER_TIME_INTERVAL
+        # ):
+        #     # 认定为当节点拍摄
+        #     # 如果为待用户确认则播放声音
+        #     data["flag"] = True
+        #     if settings.RUNNING_MODE == "待用户确认模式":
+        #         _f = False
+        #         if settings.RUNNING_MODE_DETAIL == "所有节点待确认":
+        #             _f = True
+        #         else:
+        #             print("self.is_need_confirm", self.is_need_confirm)
+        #             if self.is_need_confirm:
+        #                 _f = True
+        #             else:
+        #                 _f = False
+        #         if _f:
+        #             data["is_sound_play"] = True
+        #             print("========is_sound_play===========")
+        #             self.windows.playsound.tips_type = "photo_confirm"
+        #             self.windows.playsound.start()
+        #     return data
+        return data

+ 3 - 0
python/settings.py

@@ -14,6 +14,9 @@ def get_dict_value(_dict, key, default=None):
     else:
         return default
 MACHINE_LEVEL = "二档"
+IS_TEST = False
+IS_MCU = True
+IS_LIN_SHI_TEST = False
 
 def moveSpeed(level: str = None):
     config = {

+ 10 - 0
python/sockets/message_handler.py

@@ -54,6 +54,16 @@ async def handlerSend(
                 return
             device_ctrl = DeviceControl(websocket_manager=manager)
             device_ctrl.controlDevice(device_name, value)
+        case "run_mcu_config":
+            action = json.load(open('action.json',encoding='utf-8'))
+            left_actions = action.get("actions")
+            # data = manager.jsonMessage(code=0, msg="json消息", data=left_actions)
+            # await manager.send_personal_message(data, websocket)
+            device_ctrl = DeviceControl(websocket_manager=manager)
+            loop.create_task(
+                device_ctrl.run_mcu_config(left_actions, "123456789"),
+                name="run_mcu_config",
+            )
         case _:
             data = manager.jsonMessage(code=1, msg="未知消息")
             await manager.send_personal_message(data, websocket)