fix(edge): 配置更新时保留算法状态,避免重复告警

- 新增 update_algorithm_params() 方法,仅更新参数不重置状态机
- 修改 reload_all_algorithms() 支持 preserve_state 参数
  - preserve_state=True: 保留状态机,仅更新参数(配置更新)
  - preserve_state=False: 完全重置(手动重启)
- 修改 main.py 配置更新回调使用 preserve_state=True

修复问题:配置更新导致算法状态机重置,周界入侵CONFIRMING_CLEAR状态丢失,重新生成新告警
现在配置更新时保留告警状态,不会产生重复告警

支持算法:
- leave_post: 更新 leave_countdown_sec, working_hours 等参数
- intrusion: 更新 confirm_intrusion_seconds, confirm_clear_seconds 等参数

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-25 11:24:41 +08:00
parent 75ea66c452
commit 0b0e793785
2 changed files with 99 additions and 9 deletions

View File

@@ -97,7 +97,8 @@ class EdgeInferenceService:
if self._settings.config_sync_mode == "LOCAL" and self._config_manager:
def _on_config_update(topic, data):
if self._algorithm_manager:
self._algorithm_manager.reload_all_algorithms()
# 保留状态地更新参数,避免告警重复
self._algorithm_manager.reload_all_algorithms(preserve_state=True)
# 配置更新后清理无ROI的摄像头流
self._cleanup_cameras_without_roi()
# 配置更新后动态加载新摄像头流异步执行不阻塞HTTP响应