添加NFC绑定红外设备方式,融合车端设备和扩展设备统一控制
This commit is contained in:
@@ -200,7 +200,9 @@ def test_left_sidebar_exposes_collapsed_parsed_can_command_panel() -> None:
|
||||
assert "function parsedCanCommands(result = {})" in console
|
||||
assert "getParsedCanCommands: (result) => parsedCanCommands(result)" in console
|
||||
assert "const configurations = result.function_configs || {};" in console
|
||||
assert "const plans = result.command_plans || {};" in console
|
||||
assert "if (!configurationEntries.length && result.function_config)" in console
|
||||
assert 'deliveryLabel: submitted ? "下发" : "未下发"' in console
|
||||
assert 'data-delivery-state="${escapeHtml(item.deliveryState)}"' in console
|
||||
assert 'const command = (category, text, channel = "CAN1", frame = "")' in console
|
||||
assert 'data-can-channel="${escapeHtml(item.channel)}"' in console
|
||||
assert 'class="v2-can-command-channel"' in console
|
||||
@@ -243,6 +245,8 @@ def test_left_sidebar_exposes_collapsed_parsed_can_command_panel() -> None:
|
||||
assert ".v2-can-command-panel[open]" in styles
|
||||
assert ".v2-can-command-list li code" in styles
|
||||
assert ".v2-can-command-channel" in styles
|
||||
assert ".v2-can-command-delivery" in styles
|
||||
assert '.v2-can-command-delivery[data-delivery-state="submitted"]' in styles
|
||||
assert 'li[data-can-channel="CAN0"]' in styles
|
||||
assert ".v2-sidebar-collapsed .v2-can-command-panel" in styles
|
||||
|
||||
@@ -306,16 +310,117 @@ def test_parsed_can_command_panel_combines_can0_seat_and_can1_vehicle_commands()
|
||||
"command": "seat passenger backrest position 36",
|
||||
"frame": "0x300 · 01 12 <SEQ_LO> <SEQ_HI> 10 0E 30 75",
|
||||
"parseSource": "local_rule",
|
||||
"deliveryState": "not_submitted",
|
||||
"deliveryLabel": "未下发",
|
||||
"deliveryTransport": "有线 CAN",
|
||||
},
|
||||
{
|
||||
"channel": "CAN1",
|
||||
"category": "空调温度",
|
||||
"command": "ac temp driver 24",
|
||||
"parseSource": "cloud_supplement",
|
||||
"deliveryState": "not_submitted",
|
||||
"deliveryLabel": "未下发",
|
||||
"deliveryTransport": "有线 CAN",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def test_parsed_command_delivery_is_independent_of_transport_and_target() -> None:
|
||||
node = shutil.which("node")
|
||||
if node is None:
|
||||
return
|
||||
console = source("console-v2.js")
|
||||
start = console.index(" const normalizedCanTarget")
|
||||
end = console.index("\n\n function renderParsedCanCommands", start)
|
||||
helpers = console[start:end]
|
||||
base = {
|
||||
"function_configs": {
|
||||
"native_climate": {
|
||||
"spec": {
|
||||
"operations": [
|
||||
{
|
||||
"id": "climate-power",
|
||||
"capability": "climate.set_power",
|
||||
"target": {"zone": "vehicle"},
|
||||
"parameters": {"state": "on"},
|
||||
"parse_source": "local_rule",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
samples = [
|
||||
{**base, "execution_mode": "dry_run", "control_transport": "wired_can"},
|
||||
{
|
||||
**base,
|
||||
"execution_mode": "dry_run",
|
||||
"control_transport": "wireless_mqtt",
|
||||
},
|
||||
{
|
||||
**base,
|
||||
"execution_mode": "hardware",
|
||||
"control_transport": "wired_can",
|
||||
"execution_report": {
|
||||
"spec": {
|
||||
"results": [
|
||||
{
|
||||
"ref": "climate-power",
|
||||
"status": "succeeded",
|
||||
"telemetry": {"sent_frames": [{"frame_id": "0x1DE"}]},
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
**base,
|
||||
"execution_mode": "hardware",
|
||||
"control_transport": "wireless_mqtt",
|
||||
"execution_report": {
|
||||
"spec": {
|
||||
"results": [
|
||||
{
|
||||
"ref": "climate-power",
|
||||
"status": "succeeded",
|
||||
"telemetry": {"delivery_status": "queued"},
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
script = (
|
||||
f"{helpers}\n"
|
||||
f"const samples = {json.dumps(samples)};\n"
|
||||
"process.stdout.write(JSON.stringify(samples.map((sample) => "
|
||||
"parsedCanCommands(sample))));"
|
||||
)
|
||||
completed = subprocess.run(
|
||||
[node, "-e", script],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
parsed = json.loads(completed.stdout)
|
||||
assert [len(commands) for commands in parsed] == [1, 1, 1, 1]
|
||||
assert [commands[0]["command"] for commands in parsed] == ["ac on"] * 4
|
||||
assert [commands[0]["deliveryLabel"] for commands in parsed] == [
|
||||
"未下发",
|
||||
"未下发",
|
||||
"下发",
|
||||
"下发",
|
||||
]
|
||||
assert [commands[0]["deliveryTransport"] for commands in parsed] == [
|
||||
"有线 CAN",
|
||||
"无线 CAN",
|
||||
"有线 CAN",
|
||||
"无线 CAN",
|
||||
]
|
||||
|
||||
|
||||
def test_mode_editor_renders_readable_commands_with_expandable_mqtt_sequences() -> None:
|
||||
app = source("app.js")
|
||||
styles = source("styles.css")
|
||||
|
||||
Reference in New Issue
Block a user