Files
linuxcncWebWASM/web/react/src/gui-domain.ts

44 lines
2.6 KiB
TypeScript

import type { FrontendState } from "./store";
export const GUI_FAMILIES = ["axis", "gmoccapy", "touchy", "gscreen", "qtvcp", "qtdragon", "pyvcp", "gladevcp", "vismach", "ngcgui", "qtplasmac", "plasma"] as const;
export type GuiFamily = typeof GUI_FAMILIES[number];
export const GUI_COMMANDS = Object.freeze({
run: "PROGRAM_RUN", pause: "PROGRAM_PAUSE", resume: "PROGRAM_RESUME", step: "PROGRAM_STEP", restart: "PROGRAM_RESTART", abort: "PROGRAM_ABORT", load: "PROGRAM_LOAD", mdi: "MDI_EXECUTE", jogStart: "JOG_START", jogStop: "JOG_STOP", home: "HOME", override: "SET_OVERRIDE", estop: "ESTOP", recover: "IO_RECOVER", spindle: "SPINDLE_COMMAND", coolant: "COOLANT_COMMAND", toolPrepare: "TOOL_PREPARE", toolChange: "TOOL_CHANGE", probe: "PROBE_CONFIG", snapshot: "SNAPSHOT_REQUEST", checkpoint: "CHECKPOINT", recoverProject: "RECOVER",
} as const);
export type GuiAction = keyof typeof GUI_COMMANDS;
const GUI_PANEL_DEFINITIONS = {
axis: ["program", "preview", "dro", "manual", "mdi", "overrides", "spindle", "tool", "alarm"],
gmoccapy: ["program", "dro", "manual", "mdi", "tool", "spindle", "alarm"],
touchy: ["dro", "manual", "mdi", "program", "alarm"],
gscreen: ["program", "dro", "manual", "mdi", "hal", "alarm"],
qtvcp: ["program", "dro", "manual", "mdi", "vcp", "hal", "tool", "alarm"],
qtdragon: ["program", "dro", "manual", "mdi", "vcp", "tool", "alarm"],
pyvcp: ["dro", "manual", "vcp", "alarm"],
gladevcp: ["dro", "manual", "vcp", "hal", "alarm"],
vismach: ["preview", "dro", "manual", "program", "alarm"],
ngcgui: ["program", "mdi", "preview"],
qtplasmac: ["program", "dro", "manual", "material", "torch", "alarm"],
plasma: ["program", "dro", "manual", "material", "torch", "alarm"],
} as const satisfies Record<GuiFamily, readonly string[]>;
export const GUI_PANELS = Object.freeze(GUI_PANEL_DEFINITIONS);
export const GUI_BOUNDARIES = Object.freeze({
desktop_window: "WEB-EQUIV",
python_callbacks: "PY-WASM",
virtual_devices: "SIM-DEVICE",
source_icons: "WEB-EQUIV/SOURCE-ASSET",
host_processes: "REAL-EXCLUDED",
physical_safety: "REAL-EXCLUDED",
});
export function commandFor(action: GuiAction): string { return GUI_COMMANDS[action]; }
export function panelsForFamily(family: string): readonly string[] { return GUI_PANELS[family as GuiFamily] ?? GUI_PANELS.axis; }
export function guiStatus(state: FrontendState) {
return { session: state.status, task: state.task?.state ?? null, program: state.program?.program_status ?? null, tick: state.tick, alarms: state.alarms.length, error: state.error?.code ?? null, snapshot_hash: state.snapshot?.state_hash ?? null };
}