Wire AXIS controls through operation gates
This commit is contained in:
@@ -5,6 +5,7 @@ export const AXIS_INTERP_STATES = Object.freeze(["IDLE", "READING", "WAITING", "
|
||||
export const AXIS_MOTION_MODES = Object.freeze(["FREE", "COORD", "TELEOP"]);
|
||||
|
||||
export const AXIS_COMMANDS = Object.freeze({
|
||||
open: "LOAD_WORKSPACE", load: "PROGRAM_LOAD",
|
||||
run: "PROGRAM_RUN", step: "PROGRAM_STEP", pause: "PROGRAM_PAUSE", resume: "PROGRAM_RESUME",
|
||||
stop: "PROGRAM_ABORT", restart: "PROGRAM_RESTART", mdi: "MDI_EXECUTE", jogStart: "JOG_START",
|
||||
jogStop: "JOG_STOP", home: "HOME", override: "SET_OVERRIDE", estop: "ESTOP", recover: "IO_RECOVER",
|
||||
@@ -25,8 +26,10 @@ export function normalizeAxisState(input = {}) {
|
||||
const program = input.program ?? input.snapshot?.program ?? {};
|
||||
const motion = input.motion ?? input.snapshot?.motion ?? {};
|
||||
const devices = input.devices ?? input.snapshot?.devices ?? {};
|
||||
const taskState = string(task.state ?? input.task_state ?? input.state, "OFF");
|
||||
const interpState = string(task.interp_state ?? input.interp_state ?? input.interpreter_state, "IDLE");
|
||||
const rawTaskState = string(task.state ?? input.task_state ?? input.state, "OFF");
|
||||
const taskState = rawTaskState === "ESTOP" ? "ESTOP" : ["READY", "RUNNING", "PAUSED", "STOPPED", "ON"].includes(rawTaskState) ? "ON" : "OFF";
|
||||
const inferredInterp = rawTaskState === "RUNNING" ? "READING" : rawTaskState === "PAUSED" ? "PAUSED" : "IDLE";
|
||||
const interpState = string(task.interp_state ?? input.interp_state ?? input.interpreter_state, inferredInterp);
|
||||
const mode = string(task.mode ?? input.task_mode ?? input.mode, "MANUAL");
|
||||
const motionMode = string(motion.mode ?? input.motion_mode, "COORD");
|
||||
const programStatus = string(program.program_status ?? input.program_status, "IDLE").toLowerCase();
|
||||
@@ -36,7 +39,7 @@ export function normalizeAxisState(input = {}) {
|
||||
const limits = input.on_any_limit ?? motion.on_any_limit ?? motion.limit ?? false;
|
||||
const tool = devices.tool ?? input.tool ?? {};
|
||||
const toolNumber = number(tool.current ?? input.tool_in_spindle);
|
||||
const taskFile = Boolean(input.taskfile ?? program.path ?? program.source_hash ?? program.loaded);
|
||||
const taskFile = Boolean(input.taskfile ?? program.path ?? program.source_hash ?? program.loaded ?? (program.program_status && String(program.program_status).toLowerCase() !== "idle"));
|
||||
const hasEditor = input.has_editor !== false;
|
||||
return Object.freeze({
|
||||
taskState, interpState, mode, motionMode, programStatus, queue, queueLimit,
|
||||
@@ -60,6 +63,7 @@ export function axisGate(action, input = {}) {
|
||||
case "recover": enabled = true; reason = "axis_recover_available"; break;
|
||||
case "power": enabled = state.taskState !== "ESTOP"; reason = enabled ? "axis_power_available" : "axis_estop_active"; break;
|
||||
case "open": enabled = idle; reason = enabled ? "axis_interp_idle" : "axis_interp_running"; break;
|
||||
case "load": enabled = machineOn && idle; reason = enabled ? "axis_program_load_available" : !machineOn ? "axis_machine_off" : "axis_interp_running"; break;
|
||||
case "reload": enabled = idle && state.taskFile; reason = !idle ? "axis_interp_running" : state.taskFile ? "axis_reload_available" : "axis_taskfile_missing"; break;
|
||||
case "edit": enabled = idle && state.taskFile && state.hasEditor; reason = !idle ? "axis_interp_running" : !state.taskFile ? "axis_taskfile_missing" : !state.hasEditor ? "axis_editor_missing" : "axis_edit_available"; break;
|
||||
case "run": enabled = machineOn && idle && state.taskFile; reason = !machineOn ? "axis_machine_off" : !idle ? "axis_interp_running" : !state.taskFile ? "axis_taskfile_missing" : "axis_run_available"; break;
|
||||
|
||||
Reference in New Issue
Block a user