完善云端RUN执行反馈
This commit is contained in:
@@ -22,6 +22,11 @@ await verifyRunFeedbackLoop({
|
||||
stopAction: "STOP",
|
||||
});
|
||||
|
||||
await verifyRunReadySequence({
|
||||
profileId: "xyzac-trt",
|
||||
sourceRel: "configs/sim/axis/vismach/5axis/table-rotary-tilting/demos/xyzac_switchkins_test_1.ngc",
|
||||
});
|
||||
|
||||
await verifyRunFeedbackLoop({
|
||||
profileId: "xyzac-trt",
|
||||
sourceRel: "configs/sim/axis/vismach/5axis/table-rotary-tilting/demos/xyzac_switchkins_test_1.ngc",
|
||||
@@ -35,6 +40,7 @@ await verifyRunFeedbackLoop({
|
||||
});
|
||||
|
||||
console.log("run_feedback_status_loop_smoke=ok");
|
||||
console.log("run_ready_sequence_smoke=ok");
|
||||
|
||||
async function verifyRunFeedbackLoop({ profileId, sourceRel, stopAction }) {
|
||||
const sdk = await createLinuxCncTaskHalSdk({
|
||||
@@ -138,6 +144,65 @@ async function verifyRunFeedbackLoop({ profileId, sourceRel, stopAction }) {
|
||||
assert.equal(state.taskHalStatus.ui.taskCycle >= cycleAfterRun, true);
|
||||
}
|
||||
|
||||
async function verifyRunReadySequence({ profileId, sourceRel }) {
|
||||
const sdk = await createLinuxCncTaskHalSdk({
|
||||
wasmBinary: readFileSync(wasmPath),
|
||||
print() {},
|
||||
printErr(message) {
|
||||
console.error(message);
|
||||
},
|
||||
});
|
||||
const profile = getFiveAxisProfile(profileId);
|
||||
const iniText = readFileSync(resolve(rootDir, "wasm-port/vendor/linuxcnc", profile.iniPath), "utf8");
|
||||
const iniConfig = parseLinuxCncIni(iniText, {
|
||||
path: profile.iniPath,
|
||||
profileId: profile.id,
|
||||
});
|
||||
const store = createSimulationStore();
|
||||
|
||||
store.dispatch({ type: "ATTACH_INI_CONFIG", profileId: profile.id, iniConfig });
|
||||
store.dispatch({
|
||||
type: "ATTACH_KINEMATICS_RUNTIME",
|
||||
runtime: await createLinuxCncKinematicsRuntime({ moduleId: iniConfig.kinematicsModuleId }),
|
||||
});
|
||||
store.dispatch({
|
||||
type: "ATTACH_INTERPRETER_RUNTIME",
|
||||
runtime: await createLinuxCncInterpreterRuntime(),
|
||||
});
|
||||
store.dispatch({ type: "ATTACH_TASK_HAL_RUNTIME", runtime: wrapTaskHalSdk(sdk) });
|
||||
await store.stageMachineFiles();
|
||||
store.dispatch({ type: "LOAD_LINUXCNC_GCODE_SOURCE", sourceRel });
|
||||
await waitForState(store, (state) => (
|
||||
state.taskHalSession?.programPath?.endsWith(sourceRel.split("/").at(-1)) &&
|
||||
state.rtcpFrame?.sourceMode === "source-derived-kinematics-wasm"
|
||||
));
|
||||
|
||||
store.dispatch({ type: "RUN_READY" });
|
||||
await waitForTaskHalCommand(store);
|
||||
await waitForState(store, (state) => state.machine.taskState === "on" && state.machine.mode === "auto");
|
||||
|
||||
let state = store.getState();
|
||||
assert.equal(state.machine.powerOn, true);
|
||||
assert.equal(state.machine.taskState, "on");
|
||||
assert.equal(state.machine.mode, "auto");
|
||||
assert.equal(state.machine.allHomed, true);
|
||||
assert.equal(state.rtcpState, "on");
|
||||
assert.equal(String(state.kinsType).startsWith("tcp-"), true);
|
||||
|
||||
store.dispatch({ type: "RUN" });
|
||||
await waitForTaskHalCommand(store);
|
||||
await waitForState(store, (nextState) => distinctActiveLines(nextState.programRuntimeFeedbackHistory).length >= 2);
|
||||
|
||||
state = store.getState();
|
||||
assert.equal(state.programExecutionSourceMode, "linuxcnc-task-motion-hal-wasm");
|
||||
assert.equal(state.programRuntimeFeedback.sourceMode, "linuxcnc-task-motion-hal-wasm");
|
||||
assert.notEqual(state.operatorMessage, "run blocked: home machine first");
|
||||
assert.equal(state.machine.allHomed, true);
|
||||
|
||||
store.dispatch({ type: "STOP" });
|
||||
await waitForTaskHalCommand(store);
|
||||
}
|
||||
|
||||
async function waitForTaskHalCommand(store) {
|
||||
for (let attempt = 0; attempt < 80; attempt += 1) {
|
||||
if (!store.getState().taskHalExecutionPending) {
|
||||
|
||||
@@ -132,6 +132,11 @@ assert.equal(gate.operatorMessage, "run blocked: machine must be on");
|
||||
store.dispatch({ type: "TOGGLE_POWER" });
|
||||
gate = gateLinuxCncTaskAction(store.getState(), { type: "RUN" });
|
||||
assert.equal(gate.allowed, false);
|
||||
assert.equal(gate.operatorMessage, "run blocked: switch to auto mode first");
|
||||
|
||||
store.dispatch({ type: "SET_MODE", mode: "auto" });
|
||||
gate = gateLinuxCncTaskAction(store.getState(), { type: "RUN" });
|
||||
assert.equal(gate.allowed, false);
|
||||
assert.equal(gate.operatorMessage, "run blocked: home machine first");
|
||||
|
||||
store.dispatch({ type: "HOME" });
|
||||
|
||||
Reference in New Issue
Block a user