Browse Source

Merge remote-tracking branch 'origin/master'

panqiuyao 7 months ago
parent
commit
a6a38e27dc

+ 4 - 4
python/api.py

@@ -132,8 +132,8 @@ def fromExcelHandler(params: HandlerDetail):
     if "商品货号" not in excel_df.columns:
         raise UnicornException("缺失 [商品货号] 列")
     for index, row in excel_df.iterrows():
-        goods_art_no_image_dir = row["文件夹名称"]
-        goods_art_no = row["商品货号"]
+        goods_art_no_image_dir = str(row["文件夹名称"])
+        goods_art_no = str(row["商品货号"])
         try:
             if not goods_art_no:
                 raise UnicornException("货号不能为空")
@@ -163,8 +163,8 @@ def fromExcelHandler(params: HandlerDetail):
             for tempItem in params.temp_list:
                 temp_class[tempItem.template_id] = tempItem.template_local_classes
                 temp_name_list.append(tempItem.template_id)
-            if goods_art_no_image_dir not in path:
-                path = path + "/" + goods_art_no_image_dir
+            # if goods_art_no_image_dir not in path:
+            #     path = path + "/" + goods_art_no_image_dir
             config_data = {
                 "image_dir": path,
                 "image_order": params.template_image_order,

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

@@ -361,4 +361,149 @@ _(该命令用于单独自定义配置中某一项的单独调整测试,不进
 }
 ```
 
+
+
+#### 获取MCU其他设置信息
+<mark>以下操作需要连接设备且初始化<mark>
+* data:为null或其他值  后端忽略
+* type:
+    * 当该字段为get_mcu_other_info时,代表获取MCU其他设置信息
+##### 请求示例
+```python
+{
+    "data":null,
+    "type": "get_mcu_other_info"
+}
+```
+##### 响应示例
+* data:忽略
+* type:
+    * 当该字段为get_other_mcu_info,代表成功获取MCU其他设置信息
+<mark>以下数据包作为写入设备时对应得字段名称<mark>
+###### 成功状态
+```python
+{
+    "code": 0,
+    "msg": "获取mcu其他配置信息",
+    "status": 2,
+    "data": {
+        "is_auto_send_base_info": 0,
+        "is_move_retry": 0,
+        "is_data_response": 0,
+        "low_speed": 300,
+        "is_test": 0,
+        "to_init_mode": 1,
+        "turntable_move_to_init_mode": 0,
+        "led_count": 20,
+        "turntable_steering_angle_ratio": 356,
+        "is_manual_check": 1,
+        "camera_steering_angle_ratio": 50174,
+        "is_auto_motor_to_disable": 1,
+        "diff_dir": 0,
+        "is_auto_send_pos_info": 0,
+        "is_dog": 0,
+        "has_been_set_motor_config": 1
+    },
+    "msg_type": "get_other_mcu_info"
+}
+```
+
+
+
+#### 设置MCU其他设置信息
+<mark>以下操作需要连接设备且初始化<mark>
+* data:设置得数据包
+* type:
+    * 当该字段为set_mcu_other_info时,代表设置MCU其他设置信息
+##### 请求示例
+```python
+{
+    "data":{
+        "is_auto_send_base_info": 0,
+        "is_move_retry": 0,
+        "is_data_response": 0,
+        "low_speed": 300,
+        "is_test": 0,
+        "to_init_mode": 1,
+        "turntable_move_to_init_mode": 0,
+        "led_count": 20,
+        "turntable_steering_angle_ratio": 356,
+        "is_manual_check": 1,
+        "camera_steering_angle_ratio": 50174,
+        "is_auto_motor_to_disable": 1,
+        "diff_dir": 0,
+        "is_auto_send_pos_info": 0,
+        "is_dog": 0,
+        "has_been_set_motor_config": 1
+    },
+    "type": "set_mcu_other_info"
+}
+```
+##### 响应示例
+* data:忽略
+* type:
+    * 当该字段为get_other_mcu_info,代表成功获取MCU其他设置信息
+<mark>以下数据包作为写入设备时对应得字段名称<mark>
+###### 成功状态
+```python
+{
+    "code": 0,
+    "msg": "设置mcu其他配置信息成功",
+    "status": 2,
+    "data": null,
+    "msg_type": "set_mcu_other_info"
+}
+```
+
+
+#### 通过命令行发送设备指令
+<mark>以下操作需要连接设备且初始化<mark>
+* data:
+    * command:命令行指令,字符串“0x01 0x42 0x6C 0x6b”为前端默认展示得字符串值,写死即可
+* type:
+    * 当该字段为send_command时,代表设置通过命令行发送指令
+##### 请求示例
+```python
+{
+    "data": {
+        "command": "0x01 0x42 0x6C 0x6b"
+    },
+    "type": "send_command"
+}
+```
+##### 响应示例
+* data:
+    * command:收到的指令
+    * type:
+        * 为input时代表输入指令被转换成功,前端需要填充到发送命令得输入框中覆盖用户输入值;
+        * 为output时代表收到指令回复,前端需要填充到回复得文本展示框中;
+* type:
+    * 当该字段为send_command,代表成功获取到指令回复
+<mark>以下数据包作为写入设备时对应得字段名称<mark>
+###### 发送后指令转换
+```python
+{
+    "code": 0,
+    "msg": "命令发送完成",
+    "status": 2,
+    "data": {
+        "command": "0x01 0x42 0x6C 0x6B",
+        "type": "input"
+    },
+    "msg_type": "send_command"
+}
+```
+###### 接收到指令回复
+```python
+{
+    "code": 0,
+    "msg": "命令发送完成",
+    "status": 2,
+    "data": {
+        "command": "0xa8 0x12 0x4 0x14 0x14 0x24 0x24 0x4 0x4 0x15 0x14 0x14 0x64 0x4 0xc5 0x4 0xb6 0x84 0x1b 0x42 0x0 0x7 0x0 0x1 0x0 0x1 0x0 0x8 0x4 0x4c 0x4 0xb0 0x0 0x3 0x6b",
+        "type": "output"
+    },
+    "msg_type": "send_command"
+}
+```
 ##### 未完待续.....

+ 189 - 0
python/mcu/DebugUart.py

@@ -0,0 +1,189 @@
+import os
+import time
+
+# from lief import Object
+import asyncio
+from collections import OrderedDict
+
+
+class DebugUart():
+
+    def __init__(self, mcu):
+        # super().__init__()
+        self.mcu = mcu
+        # 0x01 0x42 0x6C 0x6b
+
+    async def set(self, text):
+        await asyncio.sleep(0.1)
+        #  1 0x42 0x6C 0x6b
+        # text = self.ui.textEdit.toPlainText()
+        # self.ui.textEdit_2.clear()
+        if not text:
+            return
+        text = text.replace(",", ",")
+        text = text.replace(" ", ",")
+        text = text.replace("\n", ",")
+        data = text.split(",")
+        try:
+            buf = [
+                self.mcu.command["signal_forwarding"],
+                0x01,
+                0x01,
+                0x00,
+                0x00,
+            ]
+            data = [int(x, 16) for x in data if x]
+            buf.extend(data)
+            text = " ".join([f"0x{x:02X}" for x in data])
+            self.mcu.msg_type = "send_command"
+            self.mcu.sendSocketMessage(
+                code=0,
+                msg="命令发送完成",
+                device_status=2,
+                data={"command": text, "type": "input"},
+            )
+            self.mcu.msg_type = "mcu"
+            # self.ui.textEdit.setText(text)
+            # # 刷新界面命令
+            # QApplication.processEvents()
+            self.mcu.add_send_data_queue(buf)
+            loop = asyncio.get_event_loop()
+            loop.create_task(self.get(), name="sendCommand3")
+        except BaseException as e:
+            print("解析错误", e)
+            pass
+
+    async def get(self, *args):
+        await asyncio.sleep(0.1)
+        self.mcu.last_from_mcu_move_respond_data = None
+        _s = time.time()
+        print("_s", _s)
+        while 1:
+            await asyncio.sleep(0.1)
+            if time.time() - _s > 3:
+                return False
+            # print("last_from_mcu_move_respond_data 1", time.time() - _s)
+            # print(
+            #     "last_from_mcu_move_respond_data 2",
+            #     self.mcu.last_from_mcu_move_respond_data,
+            # )
+            if self.mcu.last_from_mcu_move_respond_data is not None:
+                break
+        receive_data = self.mcu.last_from_mcu_move_respond_data
+        receive_data = receive_data[2:]
+        print("<------------------get_from_mcu_move_respond_data")
+        # self.ui.textEdit_2.setText(" ".join([hex(x) for x in receive_data]))
+        text = " ".join([hex(x) for x in receive_data])
+        self.mcu.msg_type = "send_command"
+        self.mcu.sendSocketMessage(
+            code=0,
+            msg="命令发送完成",
+            device_status=2,
+            data={"command": text, "type": "output"},
+        )
+        self.mcu.msg_type = "mcu"
+        if len(receive_data) >= 37:
+            # 锁定按键菜单 Lock 为 Disable(0x01 为 Enable);
+            data = OrderedDict()
+            # 锁定按键菜单 Lock 为 Disable(0x01 为 Enable);
+            data["锁定按键菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=4, len_data=1
+            )
+            # 控制模式菜单 Ctrl_Mode 为 CR_VFOC,即 FOC 矢量闭环控制模式;
+            data["控制模式菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=5, len_data=1
+            )
+            # 脉冲端口复用功能菜单 P_PUL 为 PUL_ENA,即使能脉冲输入控制
+            data["脉冲端口复用功能菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=6, len_data=1
+            )
+            # 通讯端口复用功能菜单 P_Serial 为 UART_FUN,即使能串口通讯;
+            data["通讯端口复用功能菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=7, len_data=1
+            )
+            # En 引脚的有效电平菜单 En 为 Hold,即一直有效
+            data["En引脚的有效电平菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=8, len_data=1
+            )
+            # 电机旋转正方向菜单 Dir 为 CW,即顺时针方向
+            data["电机旋转正方向菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=9, len_data=1
+            )
+            # 细分菜单 MStep 为 16 细分;(注:256 细分用 00 表示)
+            data["细分菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=10, len_data=1
+            )
+            # 细分插补功能菜单 MPlyer 为 Enable,即使能细分插补;
+            data["细分插补功能菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=11, len_data=1
+            )
+            # 自动熄屏功能菜单 AutoSDD 为 Disable,即关闭自动熄屏功能
+            data["自动熄屏功能菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=12, len_data=1
+            )
+            # 采样电流低通滤波器强度菜单 LPFilter 为 Def
+            data["采样电流低通滤波器强度菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=13, len_data=1
+            )
+            # 开环模式工作电流菜单 Ma 为 120 0Ma
+            data["开环模式工作电流菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=14, len_data=2
+            )
+            # 闭环模式最大电流菜单 Ma_Limit 为 2200Ma;
+            data["闭环模式最大电流菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=16, len_data=2
+            )
+            # 闭环模式最大转速菜单 Vm_Limit 为 3000RPM(转/每分钟);
+            data["闭环模式最大转速菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=18, len_data=2
+            )
+            # 电流环带宽菜单 CurBW_Hz 为 1000rad/s;
+            data["电流环带宽菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=20, len_data=2
+            )
+            # 串口波特率菜单 UartBaud 为 115200;(对应小屏幕选项顺序)
+            data["串口波特率菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=22, len_data=1
+            )
+            # CAN 通讯速率菜单 CAN_Baud 为 500000;(对应小屏幕选项顺序)
+            data["CAN通讯速率菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=23, len_data=1
+            )
+            # 通讯校验方式菜单 Checksum 为 0x6B;
+            data["通讯校验方式菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=24, len_data=1
+            )
+            # 控制命令应答菜单 Response 为 Receive,即只返回确认收到命令;
+            data["控制命令应答菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=25, len_data=1
+            )
+            # 通讯控制输入角度精确度选项菜单 S_PosTDP 为 Disable;
+            data["通讯控制输入角度精确度选项菜单"] = (
+                self.mcu.get_data_from_receive_data(
+                    receive_data=receive_data, start=26, len_data=1
+                )
+            )
+            # 堵转保护功能菜单 Clog_Pro 为 Enable,即使能堵转保护;
+            data["堵转保护功能菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=27, len_data=1
+            )
+            # 堵转保护转速阈值菜单 Clog_Rpm 为 8RPM(转/每分钟);
+            data["堵转保护转速阈值菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=28, len_data=2
+            )
+            # 堵转保护电流阈值菜单 Clog_Ma 为 2000Ma;
+            data["堵转保护电流阈值菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=30, len_data=2
+            )
+            # 堵转保护检测时间阈值菜单 Clog_Ms 为 2000ms;
+            data["堵转保护检测时间阈值菜单"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=32, len_data=2
+            )
+            # 位置到达窗口为 0.3
+            data["位置到达窗口"] = self.mcu.get_data_from_receive_data(
+                receive_data=receive_data, start=34, len_data=2
+            )
+
+            for k, v in data.items():
+                print("{}:{}".format(k, v))
+            return data

+ 110 - 1
python/mcu/DeviceControl.py

@@ -13,6 +13,9 @@ from .ProgramItem import ProgramItem
 from .capture.module_digicam import DigiCam
 from databases import insert_photo_records
 from .McuDeviationSet import McuDeviationSet
+from .OtherSet import OtherSet
+from .DebugUart import DebugUart
+
 # mcu命令
 class DeviceControl(BaseClass, metaclass=SingletonType):
     lock = threading.Lock()
@@ -21,6 +24,8 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
         super().__init__(websocket_manager)
         self.msg_type = "mcu"
         self.mcu_deviation_set = McuDeviationSet(self)
+        self.mcu_other_set = OtherSet(self)
+        self.debug_uart = DebugUart(self)
         self.m_t = 1
         # 0未开始  1进行中 2已结束  99异常
         self.action_state = 2
@@ -105,6 +110,52 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
             92: self.get_from_mcu_move_respond_data,  # 获取MCU响应
             100: self.print_mcu_error_data,  # 打印下位机的错误内容
         }
+    async def sendCommand(self,command):
+        await asyncio.sleep(0.01)
+        loop = asyncio.get_event_loop()
+        loop.create_task(self.debug_uart.set(command), name="sendCommand2")
+    async def getMcuOtherInfo(self):
+        await asyncio.sleep(0.01)
+        self.get_other_info()
+    async def setMcuOtherInfo(self,data):
+        await asyncio.sleep(0.01)
+        for k, v in data.items():
+            print("k:{},v:{}".format(k, v))
+            data[k] = self.setOtherMaxMinValue(k, v)
+        self.set_to_mcu_other_info(data)
+        self.msg_type = "set_other_mcu_info"
+        self.sendSocketMessage(
+            code=0,
+            msg="设置mcu其他配置信息完成",
+            device_status=2,
+        )
+        self.msg_type = "mcu"
+
+    def setOtherMaxMinValue(self,item, value):
+        value = int(value)
+        parameter_limits = {
+            "is_auto_send_base_info": (0, 10000),
+            "is_move_retry": (0, 10000),
+            "is_data_response": (0, 10000),
+            "low_speed": (0, 10000),  # 假设低速范围是0到1000
+            "is_test": (0, 10000),
+            "to_init_mode": (0, 10000),
+            "turntable_move_to_init_mode": (0, 10000),  # 假设转盘通讯方式范围是0到3
+            "led_count": (0, 10000),  # 假设LED数量范围是0到10
+            "turntable_steering_angle_ratio": (0, 10000),  # 假设角度比例范围是0到100
+            "is_manual_check": (0, 10000),
+            "camera_steering_angle_ratio": (0, 100000),  # 假设角度比例范围是0到100
+            "is_auto_motor_to_disable": (0, 10000),
+            "diff_dir": (0, 10000),
+            "is_auto_send_pos_info": (0, 10000),
+            "is_dog": (0, 10000),
+            "has_been_set_motor_config": (0, 10000),
+        }
+
+        # 获取参数的最小值和最大值
+        min_value, max_value = parameter_limits.get(item, (0, 10000))
+        value = max(min_value, min(max_value, value))
+        return value
 
     async def initDevice(self,is_force=False):
         if not self.is_running:
@@ -341,6 +392,51 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
             self.is_just_init_time = False
 
         return True
+
+    # 设置其他信息
+    def set_to_mcu_other_info(self, data):
+        is_auto_send_base_info = data["is_auto_send_base_info"]
+        is_move_retry = data["is_move_retry"]
+        is_data_response = data["is_data_response"]
+        low_speed = data["low_speed"]
+        is_test = data["is_test"]
+        to_init_mode = data["to_init_mode"]
+        turntable_move_to_init_mode = data["turntable_move_to_init_mode"]
+        led_count = data["led_count"]
+        turntable_steering_angle_ratio = data["turntable_steering_angle_ratio"]
+        is_manual_check = data["is_manual_check"]
+        camera_steering_angle_ratio = data["camera_steering_angle_ratio"]
+        is_auto_motor_to_disable = data["is_auto_motor_to_disable"]
+        diff_dir = data["diff_dir"]
+        is_auto_send_pos_info = data["is_auto_send_pos_info"]
+        is_dog = data["is_dog"]
+        has_been_set_motor_config = data["has_been_set_motor_config"]
+
+        buf = [self.command["set_other_info"]]
+        buf.extend(self.encapsulation_data(data=is_auto_send_base_info, len_data=1))
+        buf.extend(self.encapsulation_data(data=is_move_retry, len_data=1))
+        buf.extend(self.encapsulation_data(data=is_data_response, len_data=1))
+        buf.extend(self.encapsulation_data(data=low_speed, len_data=2))
+        buf.extend(self.encapsulation_data(data=is_test, len_data=1))
+        buf.extend(self.encapsulation_data(data=to_init_mode, len_data=1))
+        buf.extend(
+            self.encapsulation_data(data=turntable_move_to_init_mode, len_data=1)
+        )
+        buf.extend(self.encapsulation_data(data=led_count, len_data=2))
+        buf.extend(
+            self.encapsulation_data(data=turntable_steering_angle_ratio, len_data=2)
+        )
+        buf.extend(self.encapsulation_data(data=is_manual_check, len_data=1))
+        buf.extend(
+            self.encapsulation_data(data=camera_steering_angle_ratio, len_data=4)
+        )
+        buf.extend(self.encapsulation_data(data=is_auto_motor_to_disable, len_data=1))
+        buf.extend(self.encapsulation_data(data=diff_dir, len_data=1))
+        buf.extend(self.encapsulation_data(data=is_auto_send_pos_info, len_data=1))
+        buf.extend(self.encapsulation_data(data=is_dog, len_data=1))
+        buf.extend(self.encapsulation_data(data=has_been_set_motor_config, len_data=1))
+        self.add_send_data_queue(buf)
+
     def cleanAllReceiveData(self):
         while True:
             receive_data = self.serial_ins.read_cmd(out_time=1)
@@ -354,10 +450,14 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
             return False
         if not receive_data:
             return
-        # print("receive_data")
+        # print("receive_data", receive_data)
         # 数据 结构 command,按命令解析
         # command 0(9) 相机高度1-2  相机角度3-4  转盘角度5-6 灯光状态7  激光指示器状态8,运行状态9
         command = receive_data[0]
+        # receive_data_temp = receive_data[2:]
+        # receive_data_temp_text = " ".join([hex(x) for x in receive_data_temp])
+        # print("command",command)
+        # print("receive_data", receive_data_temp_text)
         if command in self.deal_code_func_dict:
             self.deal_code_func_dict[command](receive_data)
 
@@ -510,6 +610,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
 
     # 获取其他信息
     def get_from_mcu_other_info(self, receive_data):
+        # TODO  已完成设置
         is_auto_send_base_info = self.get_data_from_receive_data(
             receive_data=receive_data, start=1, len_data=1
         )
@@ -581,6 +682,14 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
         self.last_mcu_other_info_data["num"] += 1
         for k, v in self.last_mcu_other_info_data["data"].items():
             print("k:{},v:{}".format(k, v))
+        self.msg_type = "get_mcu_other_info"
+        self.sendSocketMessage(
+            code=0,
+            msg="获取mcu其他配置信息",
+            device_status=2,
+            data=self.last_mcu_other_info_data["data"],
+        )
+        self.msg_type = "mcu"
 
     def get_data_from_receive_data(
         self, receive_data, start, len_data, data_magnification=1

+ 241 - 0
python/mcu/OtherSet.py

@@ -0,0 +1,241 @@
+import threading
+
+import settings
+from collections import defaultdict
+import time
+from .McuDebug import McuDebug
+
+
+class OtherSet():
+    def __init__(self, mcu):
+        super().__init__()
+        self.mcu = mcu
+        self.get_value_flag = False
+        self.last_value = defaultdict(float)
+        self.mcu_debug = McuDebug(mcu, is_debug=True, is_deviation=False)
+        # self.ampy_run = None
+        # 自动获取数据
+        # QTimer.singleShot(500, self.get_data_from_mcu)
+
+    def get_data_from_mcu(self, *args):
+        self.get()
+
+    def init(self):
+        self.ui.is_auto_send_base_info.setMinimum(0)
+        self.ui.is_auto_send_base_info.setMaximum(10000)
+        self.ui.is_move_retry.setMinimum(0)
+        self.ui.is_move_retry.setMaximum(10000)
+        self.ui.is_data_response.setMinimum(0)
+        self.ui.is_data_response.setMaximum(10000)
+        self.ui.low_speed.setMinimum(0)
+        self.ui.low_speed.setMaximum(10000)
+        self.ui.is_test.setMinimum(0)
+        self.ui.is_test.setMaximum(10000)
+        self.ui.to_init_mode.setMinimum(0)
+        self.ui.to_init_mode.setMaximum(10000)
+        self.ui.turntable_move_to_init_mode.setMinimum(0)
+        self.ui.turntable_move_to_init_mode.setMaximum(10000)
+        self.ui.led_count.setMinimum(0)
+        self.ui.led_count.setMaximum(10000)
+        self.ui.turntable_steering_angle_ratio.setMinimum(0)
+        self.ui.turntable_steering_angle_ratio.setMaximum(10000)
+        self.ui.is_manual_check.setMinimum(0)
+        self.ui.is_manual_check.setMaximum(10000)
+        self.ui.camera_steering_angle_ratio.setMinimum(0)
+        self.ui.camera_steering_angle_ratio.setMaximum(100000)
+        self.ui.is_auto_motor_to_disable.setMinimum(0)
+        self.ui.is_auto_motor_to_disable.setMaximum(10000)
+        self.ui.diff_dir.setMinimum(0)
+        self.ui.diff_dir.setMaximum(10000)
+        self.ui.is_auto_send_pos_info.setMinimum(0)
+        self.ui.is_auto_send_pos_info.setMaximum(10000)
+        self.ui.is_dog.setMinimum(0)
+        self.ui.is_dog.setMaximum(10000)
+        self.ui.has_been_set_motor_config.setMinimum(0)
+        self.ui.has_been_set_motor_config.setMaximum(10000)
+        # 相机舵机
+        self.ui.camera_degree.setSingleStep(0.1)
+        self.ui.camera_degree.setMinimum(-90)
+        self.ui.camera_degree.setMaximum(90)
+        self.ui.camera_degree.valueChanged.connect(
+            lambda x: self.change_value(x, "相机舵机")
+        )
+
+        self.ui.set.clicked.connect(self.set)
+        self.ui.get.clicked.connect(self.get)
+        self.ui.init_mcu.clicked.connect(self.init_mcu)
+        self.ui.pushButton.clicked.connect(self.check_and_upload)
+        self.ui.pushButton_2.clicked.connect(self.stop_mcu)
+        # 设定相机舵机偏移量
+        self.ui.set_camera_degree.clicked.connect(
+            lambda *args: self.set_deviation("相机舵机")
+        )
+
+    def check_and_upload(self, *args):
+        try:
+            ampy_class = settings.PLUGINS_DICT["ampy_scribe"]["AMPY插件"]
+        except:
+            return
+        self.s = threading.Thread(
+            target=ampy_class(top_windows=self.windows, windows=self).run, args=()
+        )
+        self.s.start()
+
+    def stop_mcu(self, *args):
+        self.mcu.stop_mcu()
+
+    def send_log(self, text):
+        if self.mcu:
+            self.mcu.send_log(text)
+
+    # 写入文件测试
+    def init_mcu(self, *args):
+        self.mcu.to_init_device_origin_point(device_name="mcu", is_force=True)
+
+    def change_value(self, value, name):
+        value = round(value, 2)
+        if self.last_value[name] - 1 <= value <= self.last_value[name] + 1:
+            if name == "相机电机":
+                self.mcu_debug.camera_high_motor(value=value)
+            if name == "相机舵机":
+                self.mcu_debug.camera_steering(value=value)
+            if name == "转盘舵机":
+                self.mcu_debug.turntable_steering(value=value)
+            if name == "转盘前后电机":
+                self.mcu_debug.turntable_position_motor(value=value)
+            if name == "翻板舵机中位":
+                self.mcu_debug.overturn_steering(value=value)
+            if name == "翻板舵机高位":
+                self.mcu_debug.overturn_steering(value=value)
+            if name == "翻板舵机上升速度":
+                pass
+            print(value, name)
+        self.last_value[name] = value
+
+    def set_deviation(self, name, camera_steering_deviation):
+        if name == "相机舵机":
+            # 设定相机舵机偏移量
+            # camera_steering_deviation = self.ui.camera_degree.value()
+            device_name = "camera_steering"
+            self.mcu.set_deviation(
+                device_name=device_name, _type=0, deviation=camera_steering_deviation
+            )
+            # self.ui.camera_degree.setValue(0.0)
+
+    def setMcuInfo(self, data):
+        self.mcu.msg_type = "set_other_mcu_info"
+        if not self.get_value_flag:
+            self.mcu.sendSocketMessage(
+                code=1, msg="请先获取其他mcu配置信息", device_status=0, data=None
+            )
+            self.mcu.msg_type = "mcu"
+            return
+
+        # is_auto_send_base_info = data.get("is_auto_send_base_info")
+        # is_move_retry = data.get("is_move_retry")
+        # is_data_response = data.get("is_data_response")
+        # low_speed = data.get("low_speed")
+        # is_test = data.get("is_test")
+        # to_init_mode = data.get("to_init_mode")
+        # turntable_move_to_init_mode = data.get("turntable_move_to_init_mode")
+        # led_count = data.get("led_count")
+        # turntable_steering_angle_ratio = data.get("turntable_steering_angle_ratio")
+        # is_manual_check = data.get("is_manual_check")
+        # camera_steering_angle_ratio = data.get("camera_steering_angle_ratio")
+        # is_auto_motor_to_disable = data.get("is_auto_motor_to_disable")
+        # diff_dir = data.get("diff_dir")
+        # is_auto_send_pos_info = data.get("is_auto_send_pos_info")
+        # is_dog = data.get("is_dog")
+        # has_been_set_motor_config = data.get("has_been_set_motor_config")
+
+        # data = {
+        #     "is_auto_send_base_info": is_auto_send_base_info,
+        #     "is_move_retry": is_move_retry,
+        #     "is_data_response": is_data_response,
+        #     "low_speed": low_speed,
+        #     "is_test": is_test,
+        #     "to_init_mode": to_init_mode,
+        #     "turntable_move_to_init_mode": turntable_move_to_init_mode,
+        #     "led_count": led_count,
+        #     "turntable_steering_angle_ratio": turntable_steering_angle_ratio,
+        #     "is_manual_check": is_manual_check,
+        #     "camera_steering_angle_ratio": camera_steering_angle_ratio,
+        #     "is_auto_motor_to_disable": is_auto_motor_to_disable,
+        #     "diff_dir": diff_dir,
+        #     "is_auto_send_pos_info": is_auto_send_pos_info,
+        #     "is_dog": is_dog,
+        #     "has_been_set_motor_config": has_been_set_motor_config,
+        # }
+        self.mcu.set_to_mcu_other_info(data)
+        self.mcu.sendSocketMessage(code=0, msg="已完成设置", device_status=2, data=None)
+        print("已完成设置")
+        self.mcu.msg_type = "mcu"
+
+    def getMcuInfo(self, *args):
+        self.mcu.get_other_info()
+        _s = time.time()
+        last_num = self.mcu.last_mcu_other_info_data["num"]
+        print("_s", _s)
+        while 1:
+            time.sleep(0.1)
+            if time.time() - _s > 2:
+                return False
+            print(
+                "last_mcu_other_info_data  num",
+                self.mcu.last_mcu_other_info_data["num"],
+            )
+            if last_num < self.mcu.last_mcu_other_info_data["num"]:
+                data = self.mcu.last_mcu_other_info_data["data"]
+                print("获取中断", data)
+                break
+            # if self.mcu.last_mcu_other_info_data["time"] - _s > 0:
+            #     data = self.mcu.last_mcu_other_info_data["data"]
+            #     break
+        print("获取成功")
+        is_auto_send_base_info = data["is_auto_send_base_info"]
+        is_move_retry = data["is_move_retry"]
+        is_data_response = data["is_data_response"]
+        low_speed = data["low_speed"]
+        is_test = data["is_test"]
+        to_init_mode = data["to_init_mode"]
+        turntable_move_to_init_mode = data["turntable_move_to_init_mode"]
+        led_count = data["led_count"]
+        turntable_steering_angle_ratio = data["turntable_steering_angle_ratio"]
+        is_manual_check = data["is_manual_check"]
+        camera_steering_angle_ratio = data["camera_steering_angle_ratio"]
+        diff_dir = data["diff_dir"]
+        is_auto_send_pos_info = data["is_auto_send_pos_info"]
+        is_dog = data["is_dog"]
+        has_been_set_motor_config = data["has_been_set_motor_config"]
+
+        is_auto_motor_to_disable = data["is_auto_motor_to_disable"]
+        if is_auto_motor_to_disable is None:
+            is_auto_motor_to_disable = False
+        dataSend = {
+            "is_auto_send_base_info": is_auto_send_base_info,
+            "is_move_retry": is_move_retry,
+            "is_data_response": is_data_response,
+            "low_speed": low_speed,
+            "is_test": is_test,
+            "to_init_mode": to_init_mode,
+            "turntable_move_to_init_mode": turntable_move_to_init_mode,
+            "led_count": led_count,
+            "turntable_steering_angle_ratio": turntable_steering_angle_ratio,
+            "is_manual_check": is_manual_check,
+            "camera_steering_angle_ratio": camera_steering_angle_ratio,
+            "is_auto_motor_to_disable": is_auto_motor_to_disable,
+            "diff_dir": diff_dir,
+            "is_auto_send_pos_info": is_auto_send_pos_info,
+            "is_dog": is_dog,
+            "has_been_set_motor_config": has_been_set_motor_config,
+        }
+        self.get_value_flag = True
+        self.mcu.msg_type = "get_other_mcu_info"
+        self.mcu.sendSocketMessage(
+            code=0, msg="获取mcu其他配置信息", device_status=2, data=dataSend
+        )
+        self.mcu.msg_type = "mcu"
+
+    def __del__(self):
+        self.state = 2
+        self.t = None

+ 2 - 0
python/service/detail_func.py

@@ -18,6 +18,8 @@ def get_all_dir_info(image_dir, goods_art_no):
                 # 删除空文件夹
                 os.rmdir(_path)
             continue
+        print("folder_name====>", folder_name)
+        print("goods_art_no====>", goods_art_no)
         if goods_art_no == folder_name:
             folder_name_list.append(folder_name)
 

+ 18 - 0
python/sockets/message_handler.py

@@ -151,6 +151,24 @@ async def handlerSend(
                 device_ctrl.set_deviation_cmd(value, action_name, "move"),
                 name="move_deviation",
             )
+        case "get_mcu_other_info":
+            device_ctrl = DeviceControl(websocket_manager=manager)
+            loop.create_task(
+                device_ctrl.getMcuOtherInfo(),
+                name="mcu_other_set_get",
+            )
+        case "set_mcu_other_info":
+            device_ctrl = DeviceControl(websocket_manager=manager)
+            loop.create_task(
+                device_ctrl.setMcuOtherInfo(data),
+                name="setMcuOtherInfo",
+            )
+        case "send_command":
+            device_ctrl = DeviceControl(websocket_manager=manager)
+            loop.create_task(
+                device_ctrl.sendCommand(data.get("command", None)),
+                name="sendCommand",
+            )
         case _:
             data = manager.jsonMessage(code=1, msg="未知消息")
             await manager.send_personal_message(data, websocket)