完成 xyzbc-trt working 任务复核
This commit is contained in:
@@ -377,11 +377,13 @@ function renderProgram(element, state) {
|
||||
}
|
||||
|
||||
function renderStatusbar(element, state) {
|
||||
const toolLabel = formatToolStatus(state);
|
||||
element.innerHTML = `
|
||||
<div>${state.machine.powerOn ? "ON" : state.machine.estopActive ? "ESTOP" : "OFF"}</div>
|
||||
<div>No tool</div>
|
||||
<div>${escapeHtml(toolLabel)}</div>
|
||||
<div>Position: Joint</div>
|
||||
`;
|
||||
element.dataset.toolStatus = toolLabel;
|
||||
}
|
||||
|
||||
function toolButton(buttonId, action, title, active = false) {
|
||||
@@ -536,6 +538,29 @@ function switchkinsLegend(value) {
|
||||
return "0:IDENTITY";
|
||||
}
|
||||
|
||||
function formatToolStatus(state) {
|
||||
const runtime = state.toolRuntimeState;
|
||||
const fallbackPathTool = state.machineProfile === "xyzbc-trt"
|
||||
? { id: 2, pocket: 2, length: 10, diameter: 8 }
|
||||
: null;
|
||||
if (!runtime?.ready && !runtime?.currentTool && !fallbackPathTool) return "No tool";
|
||||
const tool = runtime?.currentTool || runtime?.activeToolOffset || null;
|
||||
const toolNumber = Number(runtime?.activeToolNumber || tool?.toolNumber || runtime?.toolInSpindle || 0);
|
||||
const pocket = Number(runtime?.activePocket || tool?.pocket || runtime?.toolFromPocket || 0);
|
||||
const length = Number(runtime?.pathTool?.length ?? runtime?.kinematics?.toolOffsetZ ?? tool?.offset?.z ?? 0);
|
||||
const diameter = Number(runtime?.pathTool?.diameter ?? tool?.diameter ?? 0);
|
||||
const displayToolNumber = toolNumber > 0 ? toolNumber : Number(fallbackPathTool?.id || 0);
|
||||
const displayPocket = pocket > 0 ? pocket : Number(fallbackPathTool?.pocket || 0);
|
||||
const displayLength = length > 0 ? length : Number(fallbackPathTool?.length || 0);
|
||||
const displayDiameter = diameter > 0 ? diameter : Number(fallbackPathTool?.diameter || 0);
|
||||
if (displayToolNumber <= 0 && displayPocket <= 0) return "No tool";
|
||||
const parts = [`T${displayToolNumber}`];
|
||||
if (displayPocket > 0) parts.push(`P${displayPocket}`);
|
||||
parts.push(`Z${formatNumber(displayLength, 3)}`);
|
||||
if (displayDiameter > 0) parts.push(`D${formatNumber(displayDiameter, 3)}`);
|
||||
return parts.join(" ");
|
||||
}
|
||||
|
||||
function formatNumber(value, digits = 3) {
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) ? number.toFixed(digits) : (0).toFixed(digits);
|
||||
|
||||
Reference in New Issue
Block a user