优化了副驾座椅控制
This commit is contained in:
+62
-3
@@ -75,6 +75,7 @@ const state = {
|
||||
modeDraftCommand: "",
|
||||
lastSuccessfulUtterance: "",
|
||||
modeEditor: null,
|
||||
directCanCommandPending: false,
|
||||
};
|
||||
|
||||
const $ = (selector, root = document) => root.querySelector(selector);
|
||||
@@ -7144,7 +7145,7 @@ function authoritativeCh1StatePatch(value) {
|
||||
function physicalSeatStatePatch(value) {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
||||
const source = value.source || value.feedback_source;
|
||||
if (["physical_can", "physical_can_ch0", "physical_partial"].includes(source)) {
|
||||
if (["physical_can", "physical_can_ch0", "wireless_mqtt_ch0", "physical_partial"].includes(source)) {
|
||||
return value;
|
||||
}
|
||||
const patch = {};
|
||||
@@ -7385,6 +7386,56 @@ async function postControlPhase(path, body, executionMode, onEvent = null) {
|
||||
return payload;
|
||||
}
|
||||
|
||||
async function executeCanCommands(canCommands, { deviceName = "车辆设备" } = {}) {
|
||||
const commands = Array.isArray(canCommands)
|
||||
? canCommands.map((command) => String(command || "").trim()).filter(Boolean)
|
||||
: [];
|
||||
if (!commands.length) throw new Error("没有可发送的 CAN 白名单控制指令");
|
||||
if (state.directCanCommandPending) throw new Error("上一组 CAN 控制指令仍在执行,请稍候");
|
||||
|
||||
const driverOnlyCh1 = isDriverOnlyCh1Runtime();
|
||||
if (state.executionMode === "hardware"
|
||||
&& state.controlTransport !== "wireless_mqtt"
|
||||
&& !driverOnlyCh1
|
||||
&& !isLocalDecisionHost()
|
||||
&& state.hardwareAccess?.state !== "approved") {
|
||||
throw new Error(state.hardwareAccess?.state === "pending"
|
||||
? "申请仍在等待本地审批"
|
||||
: "请先申请并获得本地真实台架使用权");
|
||||
}
|
||||
|
||||
state.directCanCommandPending = true;
|
||||
try {
|
||||
const payload = await postControlPhase(
|
||||
"/api/can/commands",
|
||||
{
|
||||
commands,
|
||||
client_type: "web_console_device_control",
|
||||
conversation_id: state.conversationId,
|
||||
vehicle_id: state.vehicleId || state.runtime?.default_vehicle_id,
|
||||
execution_mode: state.executionMode,
|
||||
control_transport: state.controlTransport,
|
||||
...(state.executionMode === "hardware"
|
||||
&& state.controlTransport !== "wireless_mqtt"
|
||||
&& !driverOnlyCh1
|
||||
? { hardware_client_id: state.hardwareClientId }
|
||||
: {}),
|
||||
...(state.executionMode === "simulated_hardware"
|
||||
? { simulation_fault: $("#simulationFault").value }
|
||||
: {}),
|
||||
},
|
||||
state.executionMode,
|
||||
);
|
||||
if (!payload) throw new Error("CAN 控制请求未返回结果");
|
||||
renderResult(payload);
|
||||
if (state.executionMode === "hardware") await synchronizePhysicalSeatState();
|
||||
showToast(`${deviceName} CAN 控制已发送`);
|
||||
return payload;
|
||||
} finally {
|
||||
state.directCanCommandPending = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function submitRequest(event) {
|
||||
event.preventDefault();
|
||||
const utterance = $("#utterance").value.trim();
|
||||
@@ -7397,6 +7448,7 @@ async function submitRequest(event) {
|
||||
}
|
||||
const driverOnlyCh1 = isDriverOnlyCh1Runtime();
|
||||
if (state.executionMode === "hardware"
|
||||
&& state.controlTransport !== "wireless_mqtt"
|
||||
&& !driverOnlyCh1
|
||||
&& !isLocalDecisionHost()
|
||||
&& state.hardwareAccess?.state !== "approved") {
|
||||
@@ -7430,7 +7482,9 @@ async function submitRequest(event) {
|
||||
execution_mode: state.executionMode,
|
||||
control_transport: state.controlTransport,
|
||||
...(state.provider === "openai" ? { reasoning_effort: state.reasoningEffort } : {}),
|
||||
...(state.executionMode === "hardware" && !driverOnlyCh1
|
||||
...(state.executionMode === "hardware"
|
||||
&& state.controlTransport !== "wireless_mqtt"
|
||||
&& !driverOnlyCh1
|
||||
? { hardware_client_id: state.hardwareClientId }
|
||||
: {}),
|
||||
...(state.executionMode === "simulated_hardware"
|
||||
@@ -7466,7 +7520,9 @@ async function submitRequest(event) {
|
||||
client_type: "web_console",
|
||||
provider: state.provider,
|
||||
reasoning_effort: state.reasoningEffort,
|
||||
...(state.executionMode === "hardware" && !driverOnlyCh1
|
||||
...(state.executionMode === "hardware"
|
||||
&& state.controlTransport !== "wireless_mqtt"
|
||||
&& !driverOnlyCh1
|
||||
? { hardware_client_id: state.hardwareClientId }
|
||||
: {}),
|
||||
},
|
||||
@@ -7630,6 +7686,9 @@ window.CognitiveAgentConsole = {
|
||||
if (autoSubmit) $("#requestForm").requestSubmit();
|
||||
return true;
|
||||
},
|
||||
executeCanCommands(canCommands, options = {}) {
|
||||
return executeCanCommands(canCommands, options);
|
||||
},
|
||||
getExecutionMode() {
|
||||
return state.executionMode;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user