|
@@ -36,8 +36,26 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
super().__init__(
|
|
super().__init__(
|
|
|
websocket_manager=websocket_manager, smart_shooter=smart_shooter
|
|
websocket_manager=websocket_manager, smart_shooter=smart_shooter
|
|
|
)
|
|
)
|
|
|
|
|
+ self.camera_height = 350
|
|
|
self.config_manager = None
|
|
self.config_manager = None
|
|
|
self.msg_type = "mcu"
|
|
self.msg_type = "mcu"
|
|
|
|
|
+ self.command = {
|
|
|
|
|
+ "to_device_move": 1, # 设备运动
|
|
|
|
|
+ "to_init_device": 2, # 初始化设备
|
|
|
|
|
+ "to_deal_other_device": 3, # 处理其他设备
|
|
|
|
|
+ "get_all_info": 29, # 获取所有信息
|
|
|
|
|
+ "set_deviation": 40, # 设置偏移量
|
|
|
|
|
+ "get_deviation": 41, # 读取偏移量
|
|
|
|
|
+ "signal_forwarding": 91, # 信号转发处理
|
|
|
|
|
+ "signal_forwarding_return": 92, # 信号转发返回
|
|
|
|
|
+ "get_other_info": 44, # 获取其他信息
|
|
|
|
|
+ "open_rgb_led": 43, ## RGB灯的处理与通讯
|
|
|
|
|
+ "set_other_info": 45, # 设置其他信息
|
|
|
|
|
+ "query_remote_control_battery": 47, # 查询遥控器电量
|
|
|
|
|
+ "set_turntable_mode": 48, # 设置转盘通讯方式 1、串口、2、无线、3 混合
|
|
|
|
|
+ "stop_mcu": 93, # 停止运行mcu
|
|
|
|
|
+ }
|
|
|
|
|
+ self.serial_ins = None
|
|
|
self.mcu_deviation_set = McuDeviationSet(self)
|
|
self.mcu_deviation_set = McuDeviationSet(self)
|
|
|
self.mcu_other_set = OtherSet(self)
|
|
self.mcu_other_set = OtherSet(self)
|
|
|
self.debug_uart = DebugUart(self)
|
|
self.debug_uart = DebugUart(self)
|
|
@@ -62,7 +80,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
self.port_name = ""
|
|
self.port_name = ""
|
|
|
self.mcu_exit = False
|
|
self.mcu_exit = False
|
|
|
self.t_n = 0
|
|
self.t_n = 0
|
|
|
- self.serial_ins = None
|
|
|
|
|
|
|
+
|
|
|
self.connected_ports_dict = {} # 已连接的ports
|
|
self.connected_ports_dict = {} # 已连接的ports
|
|
|
self.p_list = []
|
|
self.p_list = []
|
|
|
self.temp_ports_dict = {}
|
|
self.temp_ports_dict = {}
|
|
@@ -109,22 +127,7 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
"data": {},
|
|
"data": {},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- self.command = {
|
|
|
|
|
- "to_device_move": 1, # 设备运动
|
|
|
|
|
- "to_init_device": 2, # 初始化设备
|
|
|
|
|
- "to_deal_other_device": 3, # 处理其他设备
|
|
|
|
|
- "get_all_info": 29, # 获取所有信息
|
|
|
|
|
- "set_deviation": 40, # 设置偏移量
|
|
|
|
|
- "get_deviation": 41, # 读取偏移量
|
|
|
|
|
- "signal_forwarding": 91, # 信号转发处理
|
|
|
|
|
- "signal_forwarding_return": 92, # 信号转发返回
|
|
|
|
|
- "get_other_info": 44, # 获取其他信息
|
|
|
|
|
- "open_rgb_led": 43, ## RGB灯的处理与通讯
|
|
|
|
|
- "set_other_info": 45, # 设置其他信息
|
|
|
|
|
- "query_remote_control_battery": 47, # 查询遥控器电量
|
|
|
|
|
- "set_turntable_mode": 48, # 设置转盘通讯方式 1、串口、2、无线、3 混合
|
|
|
|
|
- "stop_mcu": 93, # 停止运行mcu
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
# self.window = window
|
|
# self.window = window
|
|
|
self.last_push_time = defaultdict(float)
|
|
self.last_push_time = defaultdict(float)
|
|
|
self.is_running = False
|
|
self.is_running = False
|
|
@@ -156,16 +159,26 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
return False
|
|
return False
|
|
|
cmd = [124]
|
|
cmd = [124]
|
|
|
cmd.extend([0xff & 106 >> 8, 0xff & 106])
|
|
cmd.extend([0xff & 106 >> 8, 0xff & 106])
|
|
|
- print("get_device_info cmd",cmd)
|
|
|
|
|
|
|
+ # print("get_device_info cmd",cmd)
|
|
|
data = self.get_basic_info_mcu_without_async(data=cmd)
|
|
data = self.get_basic_info_mcu_without_async(data=cmd)
|
|
|
- print("get_device_info====>",data)
|
|
|
|
|
|
|
+ # print("get_device_info====>",data)
|
|
|
if not data:
|
|
if not data:
|
|
|
return False
|
|
return False
|
|
|
return_data = self.analysis_data(data[1:])
|
|
return_data = self.analysis_data(data[1:])
|
|
|
if return_data:
|
|
if return_data:
|
|
|
- print("get_device_info====>",return_data)
|
|
|
|
|
|
|
+ camera_height = return_data.get('value',35)
|
|
|
|
|
+ self.camera_height = camera_height
|
|
|
else:
|
|
else:
|
|
|
- print("get_device_info====>","数据不存在")
|
|
|
|
|
|
|
+ self.camera_height = 350
|
|
|
|
|
+ self.msg_type = 'get_device_info'
|
|
|
|
|
+ self.sendSocketMessage(
|
|
|
|
|
+ code=0,
|
|
|
|
|
+ msg="设置mcu其他配置信息完成",
|
|
|
|
|
+ device_status=2,
|
|
|
|
|
+ data={"camera_height":self.camera_height}
|
|
|
|
|
+ )
|
|
|
|
|
+ self.msg_type = 'mcu'
|
|
|
|
|
+ return self.camera_height
|
|
|
# 获取异步数据
|
|
# 获取异步数据
|
|
|
def analysis_data(self, _data):
|
|
def analysis_data(self, _data):
|
|
|
_addr = _data[0] << 8 | _data[1]
|
|
_addr = _data[0] << 8 | _data[1]
|
|
@@ -1500,7 +1513,8 @@ class DeviceControl(BaseClass, metaclass=SingletonType):
|
|
|
else down_speed
|
|
else down_speed
|
|
|
)
|
|
)
|
|
|
value = value / 10 # value 单位毫米
|
|
value = value / 10 # value 单位毫米
|
|
|
- assert 0 <= value <= 40
|
|
|
|
|
|
|
+ max_camera_hight = self.camera_height/10
|
|
|
|
|
+ assert 0 <= value <= max_camera_hight
|
|
|
assert 0 <= max_speed <= 10000
|
|
assert 0 <= max_speed <= 10000
|
|
|
case "camera_steering":
|
|
case "camera_steering":
|
|
|
# 角度为度 未放大 精确到0.1度
|
|
# 角度为度 未放大 精确到0.1度
|