Explorar el Código

```
feat(DeviceControl): 添加随机种子和重试机制

- 在DeviceControl类中添加seed属性用于生成随机种子
- 修改move方法增加times参数控制重试次数和is_response参数
- 实现种子值自动递增和范围限制(1-9000)
- 将随机种子作为参数传递给底层数据队列
```

rambo hace 1 día
padre
commit
80ba19e09f
Se han modificado 1 ficheros con 9 adiciones y 0 borrados
  1. 9 0
      python/mcu/DeviceControl.py

+ 9 - 0
python/mcu/DeviceControl.py

@@ -47,6 +47,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
         self.state_camera_steering = 3
         self.state_camera_steering = 3
         self.state_turntable_steering = 3
         self.state_turntable_steering = 3
         self.state_overturn_steering = 3
         self.state_overturn_steering = 3
+        self.seed = 0
         self.last_camera_height = 0
         self.last_camera_height = 0
         # 是否实时获取mcu状态信息
         # 是否实时获取mcu状态信息
         self.is_get_mcu_state = True
         self.is_get_mcu_state = True
@@ -1354,10 +1355,14 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
         _is_debug=0,
         _is_debug=0,
         is_relative=0,
         is_relative=0,
         is_deviation=1,
         is_deviation=1,
+        times=2, is_response=False
     ):
     ):
         """
         """
         此处输入单位为 毫米,以及度  需要先缩小,再放大
         此处输入单位为 毫米,以及度  需要先缩小,再放大
         """
         """
+        self.seed += 1
+        if self.seed > 9000:
+            self.seed = 1
         print("移动", time.time())
         print("移动", time.time())
         logger.info("移动,%s", time.time())
         logger.info("移动,%s", time.time())
         speed = settings.moveSpeed()
         speed = settings.moveSpeed()
@@ -1450,6 +1455,10 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
             _is_debug,
             _is_debug,
             is_deviation,
             is_deviation,
             is_relative,
             is_relative,
+            times,  # 重试次数
+            0xff & self.seed >> 8,  # 随机种子
+            0xff & self.seed,  # 随机种子
+            1 if is_response is True else 0,  # 是否返回内容
         ]
         ]
         self.add_send_data_queue(data)
         self.add_send_data_queue(data)
         current_time = time.time()
         current_time = time.time()