feat(firmware): support rocking-horse workbench delivery

This commit is contained in:
Miayui
2026-09-22 11:15:13 +08:00
parent ba5dfcd6da
commit 4d99702acd
13 changed files with 250 additions and 29 deletions
@@ -33,7 +33,7 @@ PIPELINE_STAGES = (
)
TERMINAL_TASK_STATES = frozenset({"success", "failed", "canceled", "blocked"})
ACTIVE_TASK_STATES = frozenset({"waiting", "running", "pending_confirmation"})
ALL_CAPABILITIES = ("时间控制", "位置控制", "座椅通风", "座椅加热")
ALL_CAPABILITIES = ("时间控制", "位置控制", "座椅通风", "座椅加热", "动态木马")
BASELINE_CATALOG = {
"time_only": {
"name": "时间控制基线",
@@ -854,6 +854,7 @@ class FirmwareWorkbenchService:
"position_control": "位置控制" in target_capabilities,
"ventilation": "座椅通风" in target_capabilities,
"heating": "座椅加热" in target_capabilities,
"rocking_horse": "动态木马" in target_capabilities,
}
requirements = {
"task_id": task_id,
@@ -910,6 +911,19 @@ class FirmwareWorkbenchService:
"summary": "启用靠背加热分级控制与超时保护",
}
)
if "动态木马" in target_capabilities:
file_changes.extend([
{
"path": "App/seat_dynamic_mode.c",
"type": "modified",
"summary": "启用动态木马四轴循环运动、停止与超时保护",
},
{
"path": "Config/seat_dynamic_mode_config.h",
"type": "retained",
"summary": "复用已标定的木马中心姿态、往复端点与电机占空比",
},
])
task["file_changes"] = file_changes
task["code_diff"] = code_diff
self._save_locked()
@@ -936,7 +950,7 @@ class FirmwareWorkbenchService:
)
copied_hex = workspace / "Seat_Controller_demo.hex"
shutil.copy2(image_path, copied_hex)
self._finish_stage(task_id, "build", started, "IAR 编译成功,0 errors / 0 warnings。")
self._finish_stage(task_id, "build", started, "IAR 编译成功,HEX 镜像已生成。")
started = self._begin_stage(task_id, "test", "执行固件能力与工程完整性验证。")
self._check_cancel(cancel_event)
@@ -1059,11 +1073,15 @@ class FirmwareWorkbenchService:
"位置控制": ("位置", "position"),
"座椅通风": ("通风", "vent"),
"座椅加热": ("加热", "heater", "heat"),
"动态木马": ("木马", "rocking_horse", "rocking horse", "rocking-horse"),
}
for capability, aliases in patterns.items():
if any(alias in lowered for alias in aliases):
requested.append(capability)
return requested
# The ECU executes rocking-horse poses with calibrated Hall position targets.
if "动态木马" in requested and "位置控制" not in requested:
requested.append("位置控制")
return [capability for capability in ALL_CAPABILITIES if capability in requested]
def _build_log_callback(self, task_id: str) -> Callable[[str, str], None]:
def callback(level: str, line: str) -> None:
@@ -1115,6 +1133,8 @@ class FirmwareWorkbenchService:
"1" if "座椅通风" in capabilities else "0",
"-Heating",
"1" if "座椅加热" in capabilities else "0",
"-RockingHorse",
"1" if "动态木马" in capabilities else "0",
]
process = subprocess.Popen(
command,
@@ -1175,6 +1195,7 @@ class FirmwareWorkbenchService:
"position_control": "位置控制" in target_capabilities,
"ventilation": "座椅通风" in target_capabilities,
"heating": "座椅加热" in target_capabilities,
"rocking_horse": "动态木马" in target_capabilities,
}),
]
if "位置控制" in target_capabilities:
@@ -1194,6 +1215,35 @@ class FirmwareWorkbenchService:
"座椅加热控制",
"SeatBackrestHeater_SetLevel" in thermal and "MAX_ACTIVE_TIME" in heater,
))
if "动态木马" in target_capabilities:
dynamic = (self.target_root / "App" / "seat_dynamic_mode.c").read_text(
encoding="utf-8", errors="replace"
)
dynamic_config = (
self.target_root / "Config" / "seat_dynamic_mode_config.h"
).read_text(encoding="utf-8", errors="replace")
checks.extend([
("动态木马位置控制依赖", feature_profile["position_control"]),
(
"动态木马控制与停止保护",
all(token in dynamic for token in (
"SEAT_DYNAMIC_MODE_ROCKING_HORSE",
"SEAT_FEATURE_ROCKING_HORSE",
"SeatDynamicMode_Start",
"SeatDynamicMode_Stop",
"SeatDynamic_Fail",
))
and "SEAT_MOVE_OPCODE_START_DYNAMIC_MODE" in application
and "SEAT_MOVE_OPCODE_STOP_DYNAMIC_MODE" in application,
),
(
"动态木马标定与工程配置",
"SEAT_DYNAMIC_HORSE_PHASE_TIMEOUT_MS" in dynamic_config
and "SEAT_DYNAMIC_HORSE_FORWARD_M0_HALL" in dynamic_config
and "SEAT_DYNAMIC_HORSE_BACKWARD_M0_HALL" in dynamic_config
and "seat_dynamic_mode.c" in project,
),
])
checks.extend([
(
"IAR 工程模块完整性",
@@ -1245,6 +1295,7 @@ class FirmwareWorkbenchService:
"位置控制": "position",
"座椅通风": "vent",
"座椅加热": "heat",
"动态木马": "rocking-horse",
}[capability]
for capability in capabilities
)