提交代码

This commit is contained in:
root 2026-01-09 14:51:11 +08:00
parent 33a5d8b3a3
commit 36c399c009
4 changed files with 58 additions and 15 deletions

View File

@ -19,7 +19,7 @@ max_backups = 7
path = D:/BodyCheck/file/
[CAMERA1]
enabled = True
enabled = False
device_index = 0
width = 1280
height = 720
@ -29,7 +29,7 @@ fourcc = MJPG
backend = directshow
[CAMERA2]
enabled = True
enabled = False
device_index = 3
width = 1280
height = 720
@ -39,7 +39,7 @@ fourcc = MJPG
backend = directshow
[FEMTOBOLT]
enabled = True
enabled = False
algorithm_type = plt
color_resolution = 1080P
depth_mode = NFOV_2X2BINNED
@ -50,22 +50,22 @@ fps = 15
synchronized_images_only = False
[DEVICES]
imu_enabled = True
imu_enabled = False
imu_device_type = ble
imu_port = COM9
imu_mac_address = ef:3c:1a:0a:fe:02
imu_baudrate = 9600
pressure_enabled = True
pressure_enabled = False
pressure_device_type = real
pressure_use_mock = False
pressure_port = COM5
pressure_baudrate = 115200
[REMOTE]
enable = False
port = COM6
baudrate = 115200
timeout = 0.1
enable = True
strict_crc = False
[SYSTEM]

View File

@ -165,9 +165,9 @@ class DeviceCoordinator:
# 普通相机初始化两个实例camera1 与 camera2
# camera1 使用 [CAMERA1] 配置camera2 使用 [CAMERA2](若不存在则回退为 device_index+1
if self.device_configs.get('camera1', {}).get('enabled', True):
if self.device_configs.get('camera1', {}).get('enabled', False):
futures.append(('camera1', self.executor.submit(self._init_camera_by_name, 'camera1', 'CAMERA1')))
if self.device_configs.get('camera2', {}).get('enabled', True):
if self.device_configs.get('camera2', {}).get('enabled', False):
futures.append(('camera2', self.executor.submit(self._init_camera_by_name, 'camera2', 'CAMERA2')))
# IMU传感器

View File

@ -163,6 +163,8 @@ class ConfigManager:
config = self._get_imu_config()
elif device_name == 'pressure':
config = self._get_pressure_config()
elif device_name == 'remote':
config = self._get_remote_config()
else:
self.logger.warning(f"未知设备类型: {device_name}")
@ -255,6 +257,21 @@ class ConfigManager:
'calibration_samples': self.config.getint('DEVICES', 'pressure_calibration_samples', fallback=50)
}
def _get_remote_config(self) -> Dict[str, Any]:
"""
获取远程控制配置
Returns:
Dict[str, Any]: 远程控制配置
"""
return {
'enabled': self.config.getboolean('REMOTE', 'enable', fallback=True),
'port': self.config.get('REMOTE', 'port', fallback='COM6'),
'baudrate': self.config.getint('REMOTE', 'baudrate', fallback=115200),
'timeout': self.config.getfloat('REMOTE', 'timeout', fallback=0.1),
'strict_crc': self.config.getboolean('REMOTE', 'strict_crc', fallback=False)
}
def get_system_config(self) -> Dict[str, Any]:
"""
获取系统配置
@ -614,13 +631,7 @@ class ConfigManager:
'camera1': self.get_device_config('camera1'),
'camera2': self.get_device_config('camera2'),
'femtobolt': self.get_device_config('femtobolt'),
'remote': {
'enabled': self.config.getboolean('DEVICES', 'remote_enabled', fallback=True),
'port': self.config.get('REMOTE', 'port', fallback='COM6'),
'baudrate': self.config.getint('REMOTE', 'baudrate', fallback=115200),
'timeout': self.config.getfloat('REMOTE', 'timeout', fallback=0.1),
'strict_crc': self.config.getboolean('REMOTE', 'strict_crc', fallback=False)
}
'remote': self.get_device_config('remote')
}
def _batch_update_device_configs(self, configs: Dict[str, Dict[str, Any]]) -> Dict[str, Any]:
@ -787,6 +798,33 @@ class ConfigManager:
errors.append(f"FemtoBolt: {error_msg}")
self.logger.error(error_msg)
# Remote配置
if 'remote' in configs:
try:
config_data = configs['remote']
if 'enabled' in config_data:
self.set_config_value('REMOTE', 'enable', str(config_data['enabled']))
if 'port' in config_data:
self.set_config_value('REMOTE', 'port', config_data['port'])
if 'baudrate' in config_data:
self.set_config_value('REMOTE', 'baudrate', str(config_data['baudrate']))
if 'timeout' in config_data:
self.set_config_value('REMOTE', 'timeout', str(config_data['timeout']))
if 'strict_crc' in config_data:
self.set_config_value('REMOTE', 'strict_crc', str(config_data['strict_crc']))
results['remote'] = {
'success': True,
'message': '遥控器配置更新成功',
'config': config_data
}
self.logger.info(f"遥控器配置已更新: {config_data}")
except Exception as e:
error_msg = f'设置遥控器配置失败: {str(e)}'
results['remote'] = {'success': False, 'message': error_msg}
errors.append(f"Remote: {error_msg}")
self.logger.error(error_msg)
# 一次性保存所有配置
if results: # 只有在有配置更新时才保存
self.save_config()

View File

@ -752,6 +752,7 @@ const cameraStatus = computed(() => (camera1Status.value === '已连接' || came
const femtoboltStatus = ref('未连接') // (FemtoBolt)
const imuStatus = ref('未连接') // IMU
const pressureStatus = ref('未连接') //
const remoteStatus = ref('未连接') //
// videoStatuscameraStatus
const videoStatus = computed(() => cameraStatus.value)
@ -1141,6 +1142,10 @@ function connectWebSocket() {
pressureStatus.value = statusText
console.log(`⚖️ 压力传感器状态: ${statusText}`)
break
case 'remote':
remoteStatus.value = statusText
console.log(`📡 遥控器状态: ${statusText}`)
break
default:
console.warn('⚠️ 未知设备类型:', device_type)
}