Keep G-code matched to imported AC or BC machine type
This commit is contained in:
@@ -18,6 +18,7 @@ import { XyzacDiagnostics, XyzacLiveParameters, XyzacProgramPane, XyzacTrtPanel
|
||||
import { projectXyzacPanel, type XyzacOperationTrace } from "./xyzac-panel-contract";
|
||||
import { DEFAULT_MACHINE, MACHINE_DEFINITIONS, machineDefinition } from "../../workspace/machine-definitions.mjs";
|
||||
import { RtcpProgramLibrary, type RtcpProgram } from "./RtcpProgramLibrary";
|
||||
import { assertProgramMachine } from "../../workspace/program-machine-compatibility.mjs";
|
||||
import { MachineManagerPanel } from "./MachineManagerPanel";
|
||||
|
||||
export const SELECTED_XYZAC_CASE = DEFAULT_MACHINE.entrypoint;
|
||||
@@ -536,6 +537,13 @@ export function App() {
|
||||
const bundle = typeof source === "function" ? await source() : source;
|
||||
readTrtGeometry(bundle);
|
||||
const nextModel = model ? model.current : importedMachine ? updateImportedMachineGeometry(importedMachine, bundle) : null;
|
||||
const targetMachine = machineDefinition(bundle.entrypoint);
|
||||
if (!targetMachine) throw new Error("目标机床类型无法识别");
|
||||
const machineChanged = targetMachine.coordinates !== selectedMachine.coordinates;
|
||||
const nextProgramPath = machineChanged ? targetMachine.program : programPath;
|
||||
const nextProgramSource = machineChanged ? normalizeProgramSource(bundle.files?.[nextProgramPath] ?? "") : programText;
|
||||
if (!nextProgramSource.trim()) throw new Error("目标机型程序资源缺失");
|
||||
assertProgramMachine(nextProgramSource, targetMachine.coordinates, nextProgramPath);
|
||||
const configuration = toWorkerConfiguration(bundle);
|
||||
startPreviewProgress("机床参数");
|
||||
workspaceRequested = true;
|
||||
@@ -545,9 +553,11 @@ export function App() {
|
||||
setCasePath(bundle.entrypoint);
|
||||
setImportedMachine(nextModel);
|
||||
if (model) model.committed = true;
|
||||
const loaded = await operationController.execute("PROGRAM_LOAD", { source: programText, path: programPath }, { gate: false });
|
||||
finishPreviewProgress(programPath, loaded.response);
|
||||
setCommandStatus("机床参数已应用,程序已重新解析,待重新回零");
|
||||
setProgramText(nextProgramSource); setProgramPath(nextProgramPath);
|
||||
const loaded = await operationController.execute("PROGRAM_LOAD", { source: nextProgramSource, path: nextProgramPath }, { gate: false });
|
||||
finishPreviewProgress(nextProgramPath, loaded.response);
|
||||
setCaseStatus(`${targetMachine.coordinates}: ${nextProgramPath} loaded through linuxcnc-wasm`);
|
||||
setCommandStatus(machineChanged ? `已切换为 ${targetMachine.coordinates} 并加载对应程序,请重新回零` : "机床参数已应用,程序已重新解析,待重新回零");
|
||||
} catch (error) {
|
||||
if (workspaceRequested) failPreviewProgress(error instanceof Error ? error.message : String(error));
|
||||
else setCommandStatus(`机床配置未应用:${error instanceof Error ? error.message : String(error)}`);
|
||||
@@ -656,6 +666,7 @@ export function App() {
|
||||
.then(() => {
|
||||
if (!latestLoadGate.current.enabled) throw new Error(latestLoadGate.current.reason);
|
||||
markPreviewProgress(38, "wasm", "LinuxCNC WASM 正在解析刀具路径");
|
||||
assertProgramMachine(programText, selectedMachine.coordinates, programPath);
|
||||
return operationController.execute("PROGRAM_LOAD", { source: programText, path: programPath }, { state: axisState, gate: false });
|
||||
})
|
||||
.then((operation) => {
|
||||
@@ -683,6 +694,7 @@ export function App() {
|
||||
if (!source.trim()) throw new Error("program_file_empty");
|
||||
if (!latestLoadGate.current.enabled) throw new Error(latestLoadGate.current.reason);
|
||||
const path = file.name === "3D_Chips.ngc" ? "linuxcnc/nc_files/3D_Chips.ngc" : `browser/${file.name}`;
|
||||
assertProgramMachine(source, selectedMachine.coordinates, path);
|
||||
setProgramText(source);
|
||||
setProgramPath(path);
|
||||
setCommandStatus("PROGRAM_LOAD pending: waiting for LinuxCNC WASM preview");
|
||||
|
||||
1
web/react/src/legacy.d.ts
vendored
1
web/react/src/legacy.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
declare module "*.mjs" {
|
||||
export function assertProgramMachine(source: string, coordinates: string, path?: string): void;
|
||||
export const WEB_SETTINGS: typeof import("../../workspace/web-settings.json");
|
||||
export function axisImagePath(name: string, base?: string): string;
|
||||
export function readTrtConfiguration(configuration: { entrypoint: string; files: Record<string, string> }): { kinematics: { coordinates: string; axis_limits: Record<string, number[]>; axis_velocity_limits: Record<string, number> }; home_limits: Record<string, any> };
|
||||
|
||||
Reference in New Issue
Block a user