feat: sync latest run execution updates
This commit is contained in:
@@ -52,5 +52,116 @@ const events = sdk.readEvents().events;
|
||||
assert.equal(events.includes("task_plan_run"), true);
|
||||
assert.equal(events.includes("task_mdi_switchkins:M429"), true);
|
||||
|
||||
sdk.resetSession();
|
||||
sdk.initSession({
|
||||
iniPath: "xyzac-trt.ini",
|
||||
iniText: "[TRAJ]\nCOORDINATES = X Y Z A C\n",
|
||||
});
|
||||
assert.equal(sdk.stageFile("programs/feed-plan.ngc", "G1 X120 F60\nG1 X121 F600\n"), 0);
|
||||
assert.equal(sdk.openProgram("programs/feed-plan.ngc"), 0);
|
||||
assert.equal(sdk.loadProgramMotionPlan({
|
||||
programPath: "programs/feed-plan.ngc",
|
||||
segments: [
|
||||
{
|
||||
line: 1,
|
||||
type: "STRAIGHT_FEED",
|
||||
motionClass: "feed",
|
||||
feedMode: "units-per-minute",
|
||||
startSeconds: 0,
|
||||
durationSeconds: 120,
|
||||
velocityMmPerMin: 60,
|
||||
startAxes: { x: 0, y: 0, z: 0, a: 0, b: 0, c: 0 },
|
||||
endAxes: { x: 120, y: 0, z: 0, a: 0, b: 0, c: 0 },
|
||||
},
|
||||
{
|
||||
line: 2,
|
||||
type: "STRAIGHT_FEED",
|
||||
motionClass: "feed",
|
||||
feedMode: "units-per-minute",
|
||||
startSeconds: 120,
|
||||
durationSeconds: 0.1,
|
||||
velocityMmPerMin: 600,
|
||||
startAxes: { x: 120, y: 0, z: 0, a: 0, b: 0, c: 0 },
|
||||
endAxes: { x: 121, y: 0, z: 0, a: 0, b: 0, c: 0 },
|
||||
},
|
||||
],
|
||||
}), 0);
|
||||
assert.equal(sdk.sendCommand({ type: "EMC_TASK_SET_STATE", state: "ON" }), 0);
|
||||
assert.equal(sdk.sendCommand({ type: "EMC_TASK_SET_MODE", mode: "AUTO" }), 0);
|
||||
assert.equal(sdk.sendCommand({ type: "EMC_TASK_PLAN_RUN", line: 0 }), 0);
|
||||
assert.equal(sdk.runCycles({ taskCycles: 1, taskPeriodNs: 1000000000, servoPeriodNs: 1000000 }), 0);
|
||||
status = sdk.readStatus();
|
||||
assert.equal(status.motionStatus.motion.programLine, 1);
|
||||
assert.equal(status.motionStatus.axis.x > 0 && status.motionStatus.axis.x < 2, true);
|
||||
assert.equal(status.motionStatus.motion.currentVel, 1);
|
||||
assert.equal(status.motionStatus.motion.currentVel !== 60, true);
|
||||
assert.equal(sdk.runCycles({ taskCycles: 119, taskPeriodNs: 1000000000, servoPeriodNs: 1000000 }), 0);
|
||||
status = sdk.readStatus();
|
||||
assert.equal(status.motionStatus.motion.programLine, 2);
|
||||
assert.equal(status.motionStatus.motion.currentVel, 10);
|
||||
assert.equal(status.motionStatus.axis.x >= 120, true);
|
||||
|
||||
sdk.resetSession();
|
||||
sdk.initSession({
|
||||
iniPath: "xyzac-trt.ini",
|
||||
iniText: "[TRAJ]\nCOORDINATES = X Y Z A C\n",
|
||||
});
|
||||
assert.equal(sdk.stageFile("programs/comment-lines.ngc", [
|
||||
"(comment before first move)",
|
||||
"",
|
||||
"G1 X1 F60",
|
||||
"; inline comment-only line",
|
||||
"G1 X2 F60",
|
||||
"M2",
|
||||
].join("\n")), 0);
|
||||
assert.equal(sdk.openProgram("programs/comment-lines.ngc"), 0);
|
||||
assert.equal(sdk.loadProgramMotionPlan({
|
||||
programPath: "programs/comment-lines.ngc",
|
||||
segments: [
|
||||
{
|
||||
line: 3,
|
||||
type: "STRAIGHT_FEED",
|
||||
motionClass: "feed",
|
||||
feedMode: "units-per-minute",
|
||||
startSeconds: 0,
|
||||
durationSeconds: 1,
|
||||
velocityMmPerMin: 60,
|
||||
startAxes: { x: 0, y: 0, z: 0, a: 0, b: 0, c: 0 },
|
||||
endAxes: { x: 1, y: 0, z: 0, a: 0, b: 0, c: 0 },
|
||||
},
|
||||
{
|
||||
line: 5,
|
||||
type: "STRAIGHT_FEED",
|
||||
motionClass: "feed",
|
||||
feedMode: "units-per-minute",
|
||||
startSeconds: 1,
|
||||
durationSeconds: 1,
|
||||
velocityMmPerMin: 60,
|
||||
startAxes: { x: 1, y: 0, z: 0, a: 0, b: 0, c: 0 },
|
||||
endAxes: { x: 2, y: 0, z: 0, a: 0, b: 0, c: 0 },
|
||||
},
|
||||
],
|
||||
}), 0);
|
||||
assert.equal(sdk.sendCommand({ type: "EMC_TASK_SET_STATE", state: "ON" }), 0);
|
||||
assert.equal(sdk.sendCommand({ type: "EMC_TASK_SET_MODE", mode: "AUTO" }), 0);
|
||||
assert.equal(sdk.sendCommand({ type: "EMC_TASK_PLAN_RUN", line: 0 }), 0);
|
||||
assert.equal(sdk.runCycles({ taskCycles: 1, taskPeriodNs: 500000000, servoPeriodNs: 1000000 }), 0);
|
||||
status = sdk.readStatus();
|
||||
assert.equal(status.task.openedLineCount, 6);
|
||||
assert.equal(status.task.openedSourceLineCount, 6);
|
||||
assert.equal(status.task.executableLineCount, 3);
|
||||
assert.equal(status.motionStatus.motion.programLine, 3);
|
||||
assert.equal(status.halSnapshot.pins["motion.program-line"].value, 3);
|
||||
assert.equal(sdk.runCycles({ taskCycles: 1, taskPeriodNs: 600000000, servoPeriodNs: 1000000 }), 0);
|
||||
status = sdk.readStatus();
|
||||
assert.equal(status.motionStatus.motion.programLine, 5);
|
||||
assert.equal(status.halSnapshot.pins["motion.program-line"].value, 5);
|
||||
assert.equal(status.task.nextProgramLine, 5);
|
||||
assert.equal(sdk.runCycles({ taskCycles: 1, taskPeriodNs: 1000000000, servoPeriodNs: 1000000 }), 0);
|
||||
status = sdk.readStatus();
|
||||
assert.equal(status.task.nextProgramLine, 6);
|
||||
|
||||
console.log("linuxcnc_task_hal_sdk=ok");
|
||||
console.log("task_hal_sdk_status_snapshot=ok");
|
||||
console.log("task_hal_feed_timed_motion_plan=ok");
|
||||
console.log("task_hal_comment_source_line_numbers=ok");
|
||||
|
||||
Reference in New Issue
Block a user