Implement AXIS parity UI and execution baseline

This commit is contained in:
2026-08-23 07:28:37 +08:00
parent 1325504544
commit 06f96f85e5
463 changed files with 84893 additions and 692 deletions

View File

@@ -1,10 +1,24 @@
export function renderMachineView(document, { pose = { x: 0, y: 0, z: 0 }, stateHash = null } = {}) {
function finite(value) { return typeof value === "number" && Number.isFinite(value) ? value : 0; }
export function renderMachineView(document, { pose = { x: 0, y: 0, z: 0 }, joints = [], toolpath = [], stock = null, stateHash = null } = {}) {
const section = document.createElement("section"); section.className = "panel machine-panel";
const title = document.createElement("h2"); title.className = "panel-title"; title.textContent = "Machine view"; section.append(title);
const canvas = document.createElement("canvas"); canvas.className = "machine-canvas"; canvas.width = 640; canvas.height = 320; canvas.setAttribute("aria-label", "Machine position view");
const context = canvas.getContext?.("2d");
if (context) { context.fillStyle = "#0b1016"; context.fillRect(0, 0, canvas.width, canvas.height); context.strokeStyle = "#40515f"; context.strokeRect(20, 20, 600, 280); context.fillStyle = "#b4e15d"; context.beginPath(); context.arc(320 + Number(pose.x || 0) * 10, 160 - Number(pose.y || 0) * 10, 8, 0, Math.PI * 2); context.fill(); }
if (context) {
context.fillStyle = "#0b1016"; context.fillRect(0, 0, canvas.width, canvas.height);
context.strokeStyle = "#40515f"; context.strokeRect(20, 20, 600, 280);
const points = Array.isArray(toolpath) ? toolpath : [];
if (points.length > 0) {
context.strokeStyle = "#5fc4d8"; context.beginPath();
points.forEach((point, index) => { const x = 320 + finite(point?.x) * 10; const y = 160 - finite(point?.y) * 10; if (index === 0) context.moveTo?.(x, y); else context.lineTo?.(x, y); });
context.stroke?.();
}
if (stock) { context.fillStyle = "#343f48"; context.fillRect(80, 240, 480, 28); }
context.fillStyle = "#b4e15d"; context.beginPath(); context.arc(320 + finite(pose.x) * 10, 160 - finite(pose.y) * 10, 8, 0, Math.PI * 2); context.fill();
if (Array.isArray(joints) && joints.length > 0) { context.fillStyle = "#f2b56b"; joints.slice(0, 3).forEach((joint, index) => context.fillRect(40 + index * 24, 286, 12, Math.max(2, Math.min(12, Math.abs(finite(joint)))))); }
}
section.append(canvas);
const meta = document.createElement("small"); meta.textContent = `X ${pose.x ?? 0} | Y ${pose.y ?? 0} | Z ${pose.z ?? 0} | ${stateHash ?? "no hash"}`; section.append(meta);
const meta = document.createElement("small"); meta.textContent = `X ${finite(pose.x)} | Y ${finite(pose.y)} | Z ${finite(pose.z)} | joints ${Array.isArray(joints) ? joints.length : 0} | path ${Array.isArray(toolpath) ? toolpath.length : 0} | ${stateHash ?? "no hash"}`; section.append(meta);
return section;
}