修改了配置参数修改方法
This commit is contained in:
parent
e0c1353222
commit
230a0503fd
@ -14,8 +14,8 @@ a = Analysis(
|
||||
('dll/femtobolt/bin/ob_usb.dll', 'dll/femtobolt/bin'), # Orbbec USB库
|
||||
('dll/femtobolt/bin/live555.dll', 'dll/femtobolt/bin'), # Live555库
|
||||
('dll/femtobolt/bin/OrbbecSDKConfig_v1.0.xml', 'dll/femtobolt/bin'), # Orbbec配置文件 ('dll/smitsense/SMiTSenseUsb-F3.0.dll', 'dll/smitsense'), # SMiTSense传感器库
|
||||
('dll/smitsense/Wrapper.dll', 'dll/smitsense'), # Wrapper
|
||||
('dll/smitsense/SMiTSenseUsb-F3.0.dll', 'dll/smitsense'), # Wrapper
|
||||
('dll/smitsense/SMiTSenseUsb-F3.0.dll', 'dll/smitsense'), # SMiTSenseUsb库
|
||||
('dll/smitsense/Wrapper.dll', 'dll/smitsense'), # SMiTSense传感器库包装类
|
||||
],
|
||||
hiddenimports=[
|
||||
'flask',
|
||||
|
@ -179,6 +179,38 @@ class ConfigAPI:
|
||||
'message': f'设置FemtoBolt配置失败: {str(e)}'
|
||||
}), 500
|
||||
|
||||
# 批量设置所有设备配置
|
||||
@self.app.route('/api/config/devices/all', methods=['POST'])
|
||||
def set_all_device_configs():
|
||||
"""批量设置所有设备配置"""
|
||||
try:
|
||||
data = request.get_json()
|
||||
if not data:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'message': '请求数据不能为空'
|
||||
}), 400
|
||||
|
||||
# 验证数据格式
|
||||
supported_devices = ['imu', 'pressure', 'camera', 'femtobolt']
|
||||
for device_name in data.keys():
|
||||
if device_name not in supported_devices:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'message': f'不支持的设备类型: {device_name},支持的设备类型: {", ".join(supported_devices)}'
|
||||
}), 400
|
||||
|
||||
result = self.config_manager.set_all_device_configs(data)
|
||||
status_code = 200 if result['success'] else 400
|
||||
return jsonify(result), status_code
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f"批量设置设备配置失败: {e}")
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'message': f'批量设置设备配置失败: {str(e)}'
|
||||
}), 500
|
||||
|
||||
# 重新加载配置
|
||||
@self.app.route('/api/config/reload', methods=['POST'])
|
||||
def reload_config():
|
||||
|
@ -529,3 +529,73 @@ class ConfigManager:
|
||||
'camera': self.get_device_config('camera'),
|
||||
'femtobolt': self.get_device_config('femtobolt')
|
||||
}
|
||||
|
||||
def set_all_device_configs(self, configs: Dict[str, Dict[str, Any]]) -> Dict[str, Any]:
|
||||
"""
|
||||
批量设置所有设备配置
|
||||
|
||||
Args:
|
||||
configs: 所有设备配置数据
|
||||
{
|
||||
'imu': {'device_type': 'real', 'port': 'COM7', 'baudrate': 9600},
|
||||
'pressure': {'device_type': 'real', 'port': 'COM8', 'baudrate': 115200},
|
||||
'camera': {'device_index': 0, 'width': 1280, 'height': 720, 'fps': 30},
|
||||
'femtobolt': {'color_resolution': '1080P', 'depth_mode': 'NFOV_UNBINNED', 'fps': 15}
|
||||
}
|
||||
|
||||
Returns:
|
||||
Dict[str, Any]: 设置结果
|
||||
"""
|
||||
try:
|
||||
results = {}
|
||||
errors = []
|
||||
|
||||
# 逐个设置每个设备的配置
|
||||
if 'imu' in configs:
|
||||
result = self.set_imu_config(configs['imu'])
|
||||
results['imu'] = result
|
||||
if not result['success']:
|
||||
errors.append(f"IMU: {result['message']}")
|
||||
|
||||
if 'pressure' in configs:
|
||||
result = self.set_pressure_config(configs['pressure'])
|
||||
results['pressure'] = result
|
||||
if not result['success']:
|
||||
errors.append(f"压力板: {result['message']}")
|
||||
|
||||
if 'camera' in configs:
|
||||
result = self.set_camera_config(configs['camera'])
|
||||
results['camera'] = result
|
||||
if not result['success']:
|
||||
errors.append(f"相机: {result['message']}")
|
||||
|
||||
if 'femtobolt' in configs:
|
||||
result = self.set_femtobolt_config(configs['femtobolt'])
|
||||
results['femtobolt'] = result
|
||||
if not result['success']:
|
||||
errors.append(f"FemtoBolt: {result['message']}")
|
||||
|
||||
# 如果有错误,返回部分成功的结果
|
||||
if errors:
|
||||
self.logger.warning(f"部分设备配置设置失败: {'; '.join(errors)}")
|
||||
return {
|
||||
'success': False,
|
||||
'message': f'部分设备配置设置失败: {"; ".join(errors)}',
|
||||
'results': results,
|
||||
'updated_configs': self.get_all_device_configs()
|
||||
}
|
||||
else:
|
||||
self.logger.info("所有设备配置设置成功")
|
||||
return {
|
||||
'success': True,
|
||||
'message': '所有设备配置设置成功',
|
||||
'results': results,
|
||||
'updated_configs': self.get_all_device_configs()
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f"批量设置设备配置失败: {e}")
|
||||
return {
|
||||
'success': False,
|
||||
'message': f'批量设置设备配置失败: {str(e)}'
|
||||
}
|
@ -205,9 +205,9 @@ class AppServer:
|
||||
self.logger.info('正在初始化设备管理器...')
|
||||
self.device_managers = {
|
||||
'camera': CameraManager(self.socketio, self.config_manager),
|
||||
# 'femtobolt': FemtoBoltManager(self.socketio, self.config_manager),
|
||||
# 'imu': IMUManager(self.socketio, self.config_manager),
|
||||
# 'pressure': PressureManager(self.socketio, self.config_manager)
|
||||
'femtobolt': FemtoBoltManager(self.socketio, self.config_manager),
|
||||
'imu': IMUManager(self.socketio, self.config_manager),
|
||||
'pressure': PressureManager(self.socketio, self.config_manager)
|
||||
}
|
||||
|
||||
# 为每个设备添加状态变化回调
|
||||
@ -223,9 +223,9 @@ class AppServer:
|
||||
self.logger.info('设备协调器初始化完成')
|
||||
|
||||
# 启动Flask应用
|
||||
host = app_config.get('host', self.host)
|
||||
port = app_config.get('port', self.port)
|
||||
debug = app_config.get('debug', self.debug)
|
||||
host = self.host
|
||||
port = self.port
|
||||
debug = self.debug
|
||||
|
||||
self.logger.info(f'启动Flask应用 - Host: {host}, Port: {port}, Debug: {debug}')
|
||||
|
||||
@ -559,15 +559,25 @@ class AppServer:
|
||||
if not data.get(field):
|
||||
return jsonify({'success': False, 'error': f'{field}不能为空'}), 400
|
||||
|
||||
patient_id = self.db_manager.create_patient(
|
||||
name=data['name'],
|
||||
gender=data['gender'],
|
||||
age=data['age'],
|
||||
height=data.get('height'),
|
||||
weight=data.get('weight'),
|
||||
medical_history=data.get('medical_history', ''),
|
||||
notes=data.get('notes', '')
|
||||
)
|
||||
patient_data = {
|
||||
'name': data['name'],
|
||||
'gender': data['gender'],
|
||||
'age': data['age'],
|
||||
'birth_date': data.get('birth_date'),
|
||||
'nationality': data.get('nationality'),
|
||||
'residence': data.get('residence'),
|
||||
'height': data.get('height'),
|
||||
'weight': data.get('weight'),
|
||||
'shoe_size': data.get('shoe_size'),
|
||||
'phone': data.get('phone'),
|
||||
'email': data.get('email'),
|
||||
'occupation': data.get('occupation'),
|
||||
'workplace': data.get('workplace'),
|
||||
'medical_history': data.get('medical_history', ''),
|
||||
'notes': data.get('notes', '')
|
||||
}
|
||||
|
||||
patient_id = self.db_manager.create_patient(patient_data)
|
||||
|
||||
if patient_id:
|
||||
return jsonify({
|
||||
@ -603,16 +613,26 @@ class AppServer:
|
||||
try:
|
||||
data = flask_request.get_json()
|
||||
|
||||
result = self.db_manager.update_patient(
|
||||
patient_id=patient_id,
|
||||
name=data.get('name'),
|
||||
gender=data.get('gender'),
|
||||
age=data.get('age'),
|
||||
height=data.get('height'),
|
||||
weight=data.get('weight'),
|
||||
medical_history=data.get('medical_history'),
|
||||
notes=data.get('notes')
|
||||
)
|
||||
patient_data = {
|
||||
'name': data.get('name'),
|
||||
'gender': data.get('gender'),
|
||||
'age': data.get('age'),
|
||||
'birth_date': data.get('birth_date'),
|
||||
'nationality': data.get('nationality'),
|
||||
'residence': data.get('residence'),
|
||||
'height': data.get('height'),
|
||||
'weight': data.get('weight'),
|
||||
'shoe_size': data.get('shoe_size'),
|
||||
'phone': data.get('phone'),
|
||||
'email': data.get('email'),
|
||||
'occupation': data.get('occupation'),
|
||||
'workplace': data.get('workplace'),
|
||||
'medical_history': data.get('medical_history'),
|
||||
'notes': data.get('notes')
|
||||
}
|
||||
|
||||
self.db_manager.update_patient(patient_id, patient_data)
|
||||
result = True
|
||||
|
||||
if result:
|
||||
return jsonify({'success': True, 'message': '患者信息更新成功'})
|
||||
|
Loading…
Reference in New Issue
Block a user