Expand LinuxCNC smoke coverage
This commit is contained in:
@@ -66,6 +66,11 @@ The first useful target is:
|
|||||||
- 已有冷却液状态回归语料,`M7/M8/M9` 会通过 `comment.reserved` 临时输出 `10/11=mist off/on`、`20/21=flood off/on`。
|
- 已有冷却液状态回归语料,`M7/M8/M9` 会通过 `comment.reserved` 临时输出 `10/11=mist off/on`、`20/21=flood off/on`。
|
||||||
- 已有进给模式回归语料,`G93/G94/G95` 会通过 `comment.reserved` 临时输出 `93/94/95`,并通过 `set-feed` 记录 Canon feed mode 回调。
|
- 已有进给模式回归语料,`G93/G94/G95` 会通过 `comment.reserved` 临时输出 `93/94/95`,并通过 `set-feed` 记录 Canon feed mode 回调。
|
||||||
- 已有运动控制模式回归语料,`G61/G61.1/G64` 会通过 `comment.reserved` 临时输出 `611/612/640`,`feed` 暂存 G64 tolerance。
|
- 已有运动控制模式回归语料,`G61/G61.1/G64` 会通过 `comment.reserved` 临时输出 `611/612/640`,`feed` 暂存 G64 tolerance。
|
||||||
|
- smoke parser 已有固定循环第一版展开,覆盖 `G73` 高速啄钻、`G81` 普通钻、`G82` 孔底暂停钻、`G83` 啄钻、`G85` 镗孔进给退刀、`G86` 镗孔停主轴快速退刀、`G89` 镗孔暂停后进给退刀,以及 `G80` 取消、`G98/G99` 返回模式和 `L` 重复次数。
|
||||||
|
- LinuxCNC native/source 对照已扩展到 `G82` 孔底暂停和 `G83` 啄钻关键事件,覆盖孔底 dwell、啄钻深度序列和 R 平面退刀。
|
||||||
|
- smoke parser 已有 Fanuc 风格 `M98 P... L...` / `M99` 子程序调用第一版,支持同文件 `O...` 子程序块和重复调用展开;未知子程序、裸 `M99` 和过深嵌套会返回明确错误。
|
||||||
|
- smoke parser 已有 LinuxCNC 风格 O-word 子程序第一版,覆盖数字 `O100 ...` 和命名 `O<name> ...` 的 `sub` / `call [args]` / `return` / `endsub`,支持简单数字实参、`#1 = ...` 编号参数赋值、`#<name> = ...` 命名参数赋值、`X#1` / `X#<name>` 参数引用、`+ - * /` 可嵌套方括号表达式,以及 `ABS[]`、`SQRT[]`、`EXP[]`、`LN[]`、角度制 `SIN[]` / `COS[]` / `TAN[]` / `ASIN[]` / `ACOS[]`、LinuxCNC 双参数 `ATAN[]/[]`、`FIX[]` / `FUP[]` / `ROUND[]`,并拒绝和 `M98/M99` 风格混用。
|
||||||
|
- LinuxCNC native/source runner 已支持显式文件模式执行,O-word 子程序语料会通过 LinuxCNC 自身 `open/read/execute` 路径验证,而不是逐行模拟。
|
||||||
- LinuxCNC Canon bridge 会把当前解释行号补到没有自带 `lineno` 的回调事件上,方便 Web 端诊断和源码高亮。
|
- LinuxCNC Canon bridge 会把当前解释行号补到没有自带 `lineno` 的回调事件上,方便 Web 端诊断和源码高亮。
|
||||||
- 下一步是继续替换源码级链接中残留的 Python、INI/HAL、文件系统和动态加载依赖,并把 RTCP 内核接入 canon 事件流和机型配置。
|
- 下一步是继续替换源码级链接中残留的 Python、INI/HAL、文件系统和动态加载依赖,并把 RTCP 内核接入 canon 事件流和机型配置。
|
||||||
|
|
||||||
@@ -92,6 +97,10 @@ The first useful target is:
|
|||||||
- `M7` / `M8` / `M9` 冷却液状态回归
|
- `M7` / `M8` / `M9` 冷却液状态回归
|
||||||
- `G93` / `G94` / `G95` 进给模式回归
|
- `G93` / `G94` / `G95` 进给模式回归
|
||||||
- `G61` / `G61.1` / `G64` 运动控制模式回归
|
- `G61` / `G61.1` / `G64` 运动控制模式回归
|
||||||
|
- smoke parser `G73` / `G81` / `G82` / `G83` / `G85` / `G86` / `G89` / `G80` / `G98` / `G99` / `L` 固定循环展开回归
|
||||||
|
- LinuxCNC native/source `G82` / `G83` 固定循环对照回归
|
||||||
|
- smoke parser `M98 P... L...` / `M99` 子程序调用回归
|
||||||
|
- smoke parser LinuxCNC 风格 `O... sub/call/return/endsub` 子程序调用回归
|
||||||
- `G10 L2` / `G10 L20` / `G92.1` 坐标系事件回归
|
- `G10 L2` / `G10 L20` / `G92.1` 坐标系事件回归
|
||||||
- `G38.3` 探针事件回归
|
- `G38.3` 探针事件回归
|
||||||
|
|
||||||
|
|||||||
@@ -439,7 +439,19 @@ void USE_NO_SPINDLE_FORCE() {
|
|||||||
void SET_TOOL_TABLE_ENTRY(int, int, const EmcPose &, double, double, double, int) {
|
void SET_TOOL_TABLE_ENTRY(int, int, const EmcPose &, double, double, double, int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void USE_TOOL_LENGTH_OFFSET(const EmcPose &) {
|
void USE_TOOL_LENGTH_OFFSET(const EmcPose &offset) {
|
||||||
|
if (!active_sink) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CncSimEvent event{};
|
||||||
|
event.version = 1;
|
||||||
|
event.type = CNC_SIM_EVENT_COMMENT;
|
||||||
|
event.line = event_line();
|
||||||
|
event.reserved = 430;
|
||||||
|
event.start = make_pose(offset.tran.x, offset.tran.y, offset.tran.z,
|
||||||
|
offset.a, offset.b, offset.c,
|
||||||
|
offset.u, offset.v, offset.w);
|
||||||
|
active_sink->emit_raw(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHANGE_TOOL_NUMBER(int number) {
|
void CHANGE_TOOL_NUMBER(int number) {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <fstream>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
int _task = 0;
|
int _task = 0;
|
||||||
char _parameter_file_name[LINELEN];
|
char _parameter_file_name[LINELEN];
|
||||||
@@ -88,6 +90,92 @@ std::string interp_error(InterpBase *interp, int status, const char *stage) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool file_mode_enabled() {
|
||||||
|
return std::getenv("CNC_SIM_RS274_FILE_MODE") != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool write_temp_program(const char *program,
|
||||||
|
size_t program_len,
|
||||||
|
std::string *path,
|
||||||
|
std::string *error) {
|
||||||
|
char tmpl[] = "/tmp/cnc_sim_api_XXXXXX.ngc";
|
||||||
|
const int fd = mkstemps(tmpl, 4);
|
||||||
|
if (fd < 0) {
|
||||||
|
if (error) {
|
||||||
|
*error = "failed to create temporary ngc file";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ok = true;
|
||||||
|
size_t written = 0;
|
||||||
|
while (written < program_len) {
|
||||||
|
const ssize_t rc = write(fd, program + written, program_len - written);
|
||||||
|
if (rc <= 0) {
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
written += static_cast<size_t>(rc);
|
||||||
|
}
|
||||||
|
if (close(fd) != 0) {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
unlink(tmpl);
|
||||||
|
if (error) {
|
||||||
|
*error = "failed to write temporary ngc file";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*path = tmpl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int execute_file_mode(InterpBase *interp,
|
||||||
|
CanonEventSink &sink,
|
||||||
|
const std::string &path,
|
||||||
|
std::string *error) {
|
||||||
|
int status = interp->open(path.c_str());
|
||||||
|
if (status != INTERP_OK) {
|
||||||
|
if (error) {
|
||||||
|
*error = interp_error(interp, status, "open");
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool program_done = false;
|
||||||
|
while (!program_done) {
|
||||||
|
status = interp->read();
|
||||||
|
if (status == INTERP_EXIT || status == INTERP_ENDFILE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!normal_read_status(status)) {
|
||||||
|
if (error) {
|
||||||
|
*error = interp_error(interp, status, "read");
|
||||||
|
}
|
||||||
|
interp->close();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cnc_sim_linuxcnc_set_current_line(interp->line());
|
||||||
|
status = interp->execute();
|
||||||
|
if (!normal_execute_status(status, &program_done)) {
|
||||||
|
if (error) {
|
||||||
|
*error = interp_error(interp, status, "execute");
|
||||||
|
}
|
||||||
|
interp->close();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (stop_if_callback_aborted(sink, error)) {
|
||||||
|
interp->close();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interp->close();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int parse_linuxcnc_rs274_backend(CanonEventSink &sink,
|
int parse_linuxcnc_rs274_backend(CanonEventSink &sink,
|
||||||
@@ -119,57 +207,82 @@ int parse_linuxcnc_rs274_backend(CanonEventSink &sink,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string source(program, program + program_len);
|
if (file_mode_enabled()) {
|
||||||
std::istringstream input(source);
|
std::string temp_path;
|
||||||
std::string line;
|
if (!write_temp_program(program, program_len, &temp_path, error)) {
|
||||||
bool program_done = false;
|
interp->exit();
|
||||||
int line_number = 0;
|
delete interp;
|
||||||
while (!program_done && std::getline(input, line)) {
|
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
||||||
++line_number;
|
return -1;
|
||||||
cnc_sim_linuxcnc_set_current_line(line_number);
|
}
|
||||||
std::vector<SimulatorGcodeControlAction> control_actions;
|
const int rc = execute_file_mode(interp, sink, temp_path, error);
|
||||||
if (parse_simulator_gcode_control_line(line, &control_actions)) {
|
unlink(temp_path.c_str());
|
||||||
for (const auto &action : control_actions) {
|
if (rc != 0) {
|
||||||
emit_simulator_gcode_control_action(sink, action, line_number);
|
interp->exit();
|
||||||
if (stop_if_callback_aborted(sink, error)) {
|
delete interp;
|
||||||
interp->exit();
|
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
||||||
delete interp;
|
return -1;
|
||||||
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
}
|
||||||
return -1;
|
} else {
|
||||||
|
std::string source(program, program + program_len);
|
||||||
|
std::istringstream input(source);
|
||||||
|
std::string line;
|
||||||
|
bool program_done = false;
|
||||||
|
int line_number = 0;
|
||||||
|
while (!program_done && std::getline(input, line)) {
|
||||||
|
++line_number;
|
||||||
|
cnc_sim_linuxcnc_set_current_line(line_number);
|
||||||
|
std::vector<SimulatorGcodeControlAction> control_actions;
|
||||||
|
if (parse_simulator_gcode_control_line(line, &control_actions)) {
|
||||||
|
bool simulator_only_line = true;
|
||||||
|
for (const auto &action : control_actions) {
|
||||||
|
emit_simulator_gcode_control_action(sink, action, line_number);
|
||||||
|
if (action.kind == SimulatorGcodeControlKind::RtcpState &&
|
||||||
|
!action.rtcp_enabled) {
|
||||||
|
simulator_only_line = false;
|
||||||
|
}
|
||||||
|
if (stop_if_callback_aborted(sink, error)) {
|
||||||
|
interp->exit();
|
||||||
|
delete interp;
|
||||||
|
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (simulator_only_line) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = interp->read(line.c_str());
|
status = interp->read(line.c_str());
|
||||||
if (!normal_read_status(status)) {
|
if (!normal_read_status(status)) {
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = interp_error(interp, status, "read");
|
*error = interp_error(interp, status, "read");
|
||||||
|
}
|
||||||
|
interp->exit();
|
||||||
|
delete interp;
|
||||||
|
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (status == INTERP_EXIT || status == INTERP_ENDFILE) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
interp->exit();
|
|
||||||
delete interp;
|
|
||||||
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (status == INTERP_EXIT || status == INTERP_ENDFILE) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = interp->execute();
|
status = interp->execute();
|
||||||
if (!normal_execute_status(status, &program_done)) {
|
if (!normal_execute_status(status, &program_done)) {
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = interp_error(interp, status, "execute");
|
*error = interp_error(interp, status, "execute");
|
||||||
|
}
|
||||||
|
interp->exit();
|
||||||
|
delete interp;
|
||||||
|
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (stop_if_callback_aborted(sink, error)) {
|
||||||
|
interp->exit();
|
||||||
|
delete interp;
|
||||||
|
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
interp->exit();
|
|
||||||
delete interp;
|
|
||||||
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (stop_if_callback_aborted(sink, error)) {
|
|
||||||
interp->exit();
|
|
||||||
delete interp;
|
|
||||||
cnc_sim_linuxcnc_set_canon_sink(nullptr);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -14,5 +14,16 @@ public:
|
|||||||
private:
|
private:
|
||||||
CanonEventSink &sink_;
|
CanonEventSink &sink_;
|
||||||
bool absolute_ = true;
|
bool absolute_ = true;
|
||||||
|
int canned_cycle_ = 0;
|
||||||
|
bool canned_return_to_initial_ = false;
|
||||||
|
bool canned_has_r_ = false;
|
||||||
|
bool canned_has_z_ = false;
|
||||||
|
bool canned_has_p_ = false;
|
||||||
|
bool canned_has_q_ = false;
|
||||||
|
bool canned_has_d_ = false;
|
||||||
|
double canned_r_ = 0.0;
|
||||||
|
double canned_z_ = 0.0;
|
||||||
|
double canned_p_ = 0.0;
|
||||||
|
double canned_q_ = 0.0;
|
||||||
|
double canned_d_ = 1.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ int main() {
|
|||||||
bool saw_g61_mode = false;
|
bool saw_g61_mode = false;
|
||||||
bool saw_g611_mode = false;
|
bool saw_g611_mode = false;
|
||||||
bool saw_g64_mode = false;
|
bool saw_g64_mode = false;
|
||||||
|
bool saw_tool_length = false;
|
||||||
|
bool saw_tool_length_clear = false;
|
||||||
for (const auto &event : events) {
|
for (const auto &event : events) {
|
||||||
saw_tool = saw_tool || event.type == CNC_SIM_EVENT_TOOL_CHANGE;
|
saw_tool = saw_tool || event.type == CNC_SIM_EVENT_TOOL_CHANGE;
|
||||||
saw_rapid = saw_rapid || event.type == CNC_SIM_EVENT_RAPID;
|
saw_rapid = saw_rapid || event.type == CNC_SIM_EVENT_RAPID;
|
||||||
@@ -316,6 +318,29 @@ int main() {
|
|||||||
ok &= expect(saw_g611_mode, "expected LinuxCNC G61.1 exact stop mode");
|
ok &= expect(saw_g611_mode, "expected LinuxCNC G61.1 exact stop mode");
|
||||||
ok &= expect(saw_g64_mode, "expected LinuxCNC G64 continuous mode");
|
ok &= expect(saw_g64_mode, "expected LinuxCNC G64 continuous mode");
|
||||||
|
|
||||||
|
const char tool_length_program[] =
|
||||||
|
"G21 G90 G17\n"
|
||||||
|
"G43 H1\n"
|
||||||
|
"G49\n"
|
||||||
|
"M30\n";
|
||||||
|
events.clear();
|
||||||
|
ok &= expect(cnc_sim_parse_program(sim, tool_length_program, sizeof(tool_length_program) - 1) == 0,
|
||||||
|
cnc_sim_last_error(sim));
|
||||||
|
for (const auto &event : events) {
|
||||||
|
saw_tool_length = saw_tool_length ||
|
||||||
|
(event.type == CNC_SIM_EVENT_COMMENT &&
|
||||||
|
event.line == 2 &&
|
||||||
|
event.reserved == 430 &&
|
||||||
|
event.start.z == 0.0);
|
||||||
|
saw_tool_length_clear = saw_tool_length_clear ||
|
||||||
|
(event.type == CNC_SIM_EVENT_COMMENT &&
|
||||||
|
event.line == 3 &&
|
||||||
|
event.reserved == 430 &&
|
||||||
|
event.start.z == 0.0);
|
||||||
|
}
|
||||||
|
ok &= expect(saw_tool_length, "expected LinuxCNC G43 H1 tool length event");
|
||||||
|
ok &= expect(saw_tool_length_clear, "expected LinuxCNC G49 tool length clear event");
|
||||||
|
|
||||||
const char comment_program[] =
|
const char comment_program[] =
|
||||||
"G21 G90 G17\n"
|
"G21 G90 G17\n"
|
||||||
"(operator note)\n"
|
"(operator note)\n"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -49,6 +49,10 @@ int main() {
|
|||||||
SET_G5X_OFFSET(1, 10.0, 20.0, 30.0, 1.0, 2.0, 3.0, 0.0, 0.0, 0.0);
|
SET_G5X_OFFSET(1, 10.0, 20.0, 30.0, 1.0, 2.0, 3.0, 0.0, 0.0, 0.0);
|
||||||
SET_G92_OFFSET(1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
SET_G92_OFFSET(1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
||||||
SET_XY_ROTATION(15.0);
|
SET_XY_ROTATION(15.0);
|
||||||
|
EmcPose tool_offset{};
|
||||||
|
tool_offset.tran.z = 12.5;
|
||||||
|
cnc_sim_linuxcnc_set_current_line(19);
|
||||||
|
USE_TOOL_LENGTH_OFFSET(tool_offset);
|
||||||
cnc_sim_linuxcnc_set_current_line(20);
|
cnc_sim_linuxcnc_set_current_line(20);
|
||||||
COMMENT("bridge comment");
|
COMMENT("bridge comment");
|
||||||
cnc_sim_linuxcnc_set_current_line(24);
|
cnc_sim_linuxcnc_set_current_line(24);
|
||||||
@@ -83,6 +87,7 @@ int main() {
|
|||||||
bool saw_g5x = false;
|
bool saw_g5x = false;
|
||||||
bool saw_g92 = false;
|
bool saw_g92 = false;
|
||||||
bool saw_rotation = false;
|
bool saw_rotation = false;
|
||||||
|
bool saw_tool_length = false;
|
||||||
bool saw_comment = false;
|
bool saw_comment = false;
|
||||||
bool saw_mist_on = false;
|
bool saw_mist_on = false;
|
||||||
bool saw_flood_on = false;
|
bool saw_flood_on = false;
|
||||||
@@ -131,6 +136,10 @@ int main() {
|
|||||||
event.start.z == 3.0);
|
event.start.z == 3.0);
|
||||||
saw_rotation = saw_rotation || (event.type == CNC_SIM_EVENT_SET_XY_ROTATION &&
|
saw_rotation = saw_rotation || (event.type == CNC_SIM_EVENT_SET_XY_ROTATION &&
|
||||||
event.feed == 15.0);
|
event.feed == 15.0);
|
||||||
|
saw_tool_length = saw_tool_length || (event.type == CNC_SIM_EVENT_COMMENT &&
|
||||||
|
event.line == 19 &&
|
||||||
|
event.reserved == 430 &&
|
||||||
|
event.start.z == 12.5);
|
||||||
saw_comment = saw_comment || (event.type == CNC_SIM_EVENT_COMMENT &&
|
saw_comment = saw_comment || (event.type == CNC_SIM_EVENT_COMMENT &&
|
||||||
event.line == 20);
|
event.line == 20);
|
||||||
saw_mist_on = saw_mist_on || (event.type == CNC_SIM_EVENT_COMMENT &&
|
saw_mist_on = saw_mist_on || (event.type == CNC_SIM_EVENT_COMMENT &&
|
||||||
@@ -169,6 +178,7 @@ int main() {
|
|||||||
ok &= expect(saw_g5x, "expected G5X offset event");
|
ok &= expect(saw_g5x, "expected G5X offset event");
|
||||||
ok &= expect(saw_g92, "expected G92 offset event");
|
ok &= expect(saw_g92, "expected G92 offset event");
|
||||||
ok &= expect(saw_rotation, "expected XY rotation event");
|
ok &= expect(saw_rotation, "expected XY rotation event");
|
||||||
|
ok &= expect(saw_tool_length, "expected tool length offset event");
|
||||||
ok &= expect(saw_comment, "expected comment event line");
|
ok &= expect(saw_comment, "expected comment event line");
|
||||||
ok &= expect(saw_mist_on, "expected mist on state");
|
ok &= expect(saw_mist_on, "expected mist on state");
|
||||||
ok &= expect(saw_flood_on, "expected flood on state");
|
ok &= expect(saw_flood_on, "expected flood on state");
|
||||||
|
|||||||
@@ -136,14 +136,21 @@ bool execute_line(InterpBase *interp,
|
|||||||
cnc_sim_linuxcnc_set_current_line(line_number);
|
cnc_sim_linuxcnc_set_current_line(line_number);
|
||||||
std::vector<SimulatorGcodeControlAction> control_actions;
|
std::vector<SimulatorGcodeControlAction> control_actions;
|
||||||
if (parse_simulator_gcode_control_line(line, &control_actions)) {
|
if (parse_simulator_gcode_control_line(line, &control_actions)) {
|
||||||
|
bool simulator_only_line = true;
|
||||||
for (const auto &action : control_actions) {
|
for (const auto &action : control_actions) {
|
||||||
emit_simulator_gcode_control_action(sink, action, line_number);
|
emit_simulator_gcode_control_action(sink, action, line_number);
|
||||||
|
if (action.kind == SimulatorGcodeControlKind::RtcpState &&
|
||||||
|
!action.rtcp_enabled) {
|
||||||
|
simulator_only_line = false;
|
||||||
|
}
|
||||||
if (sink.callback_aborted()) {
|
if (sink.callback_aborted()) {
|
||||||
std::cerr << "event callback aborted parsing\n";
|
std::cerr << "event callback aborted parsing\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
if (simulator_only_line) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trace_enabled()) {
|
if (trace_enabled()) {
|
||||||
@@ -183,6 +190,54 @@ bool execute_line(InterpBase *interp,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool execute_open_file(InterpBase *interp, const char *path) {
|
||||||
|
if (trace_enabled()) {
|
||||||
|
std::cerr << "rs274:open " << path << '\n';
|
||||||
|
}
|
||||||
|
int rc = interp->open(path);
|
||||||
|
if (rc != 0) {
|
||||||
|
char error[1024]{};
|
||||||
|
interp->error_text(rc, error, sizeof(error));
|
||||||
|
std::cerr << "open failed: " << error << '\n';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ok = true;
|
||||||
|
bool program_done = false;
|
||||||
|
while (!program_done) {
|
||||||
|
rc = interp->read();
|
||||||
|
if (rc == INTERP_ENDFILE || rc == INTERP_EXIT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (rc != 0) {
|
||||||
|
char error[1024]{};
|
||||||
|
interp->error_text(rc, error, sizeof(error));
|
||||||
|
std::cerr << "read failed: " << error << '\n';
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cnc_sim_linuxcnc_set_current_line(interp->line());
|
||||||
|
if (trace_enabled()) {
|
||||||
|
std::cerr << "rs274:execute file line " << interp->line() << '\n';
|
||||||
|
}
|
||||||
|
rc = interp->execute();
|
||||||
|
if (rc == INTERP_EXIT || rc == INTERP_ENDFILE) {
|
||||||
|
program_done = true;
|
||||||
|
} else if (rc == INTERP_EXECUTE_FINISH || rc == INTERP_OK) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
char error[1024]{};
|
||||||
|
interp->error_text(rc, error, sizeof(error));
|
||||||
|
std::cerr << "execute failed: " << error << '\n';
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
interp->close();
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
void init_minimal_tooldata() {
|
void init_minimal_tooldata() {
|
||||||
tool_mmap_creator(nullptr, 0);
|
tool_mmap_creator(nullptr, 0);
|
||||||
tooldata_reset();
|
tooldata_reset();
|
||||||
@@ -202,7 +257,10 @@ void init_minimal_tooldata() {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
const std::string program = read_all(argc > 1 ? argv[1] : "-");
|
const bool use_file_mode = std::getenv("CNC_SIM_RS274_FILE_MODE") != nullptr &&
|
||||||
|
argc > 1 &&
|
||||||
|
std::string(argv[1]) != "-";
|
||||||
|
const std::string program = use_file_mode ? std::string{} : read_all(argc > 1 ? argv[1] : "-");
|
||||||
if (const char *parameter_file = std::getenv("CNC_SIM_RS274_VAR")) {
|
if (const char *parameter_file = std::getenv("CNC_SIM_RS274_VAR")) {
|
||||||
SET_PARAMETER_FILE_NAME(parameter_file);
|
SET_PARAMETER_FILE_NAME(parameter_file);
|
||||||
}
|
}
|
||||||
@@ -230,16 +288,20 @@ int main(int argc, char **argv) {
|
|||||||
std::cerr << "rs274:init done\n";
|
std::cerr << "rs274:init done\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istringstream input(program);
|
|
||||||
std::string line;
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
bool program_done = false;
|
if (use_file_mode) {
|
||||||
int line_number = 0;
|
ok = execute_open_file(interp, argv[1]);
|
||||||
while (!program_done && std::getline(input, line)) {
|
} else {
|
||||||
++line_number;
|
std::istringstream input(program);
|
||||||
if (!execute_line(interp, sink, line, line_number, &program_done)) {
|
std::string line;
|
||||||
ok = false;
|
bool program_done = false;
|
||||||
break;
|
int line_number = 0;
|
||||||
|
while (!program_done && std::getline(input, line)) {
|
||||||
|
++line_number;
|
||||||
|
if (!execute_line(interp, sink, line, line_number, &program_done)) {
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "\n]\n";
|
std::cout << "\n]\n";
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ This parser only exists to test the ABI and UI before Emscripten and LinuxCNC ar
|
|||||||
- `G4 P...`
|
- `G4 P...`
|
||||||
- `F`, `S`, `T`, `M3`, `M4`, `M5`, `M6`, `M2`, `M30`
|
- `F`, `S`, `T`, `M3`, `M4`, `M5`, `M6`, `M2`, `M30`
|
||||||
- IJK and R arcs
|
- IJK and R arcs
|
||||||
|
- numbered and named parameter assignment/reference such as `#1 = ...`, `#<name> = ...`, `X#1`, and nested expressions like `X[[#<name> + 2] * 3]`
|
||||||
|
- expression functions `ABS[]`, `SQRT[]`, `EXP[]`, `LN[]`, degree-based `SIN[]`/`COS[]`/`TAN[]`/`ASIN[]`/`ACOS[]`, LinuxCNC-style `ATAN[]/[]`, and `FIX[]`/`FUP[]`/`ROUND[]`
|
||||||
|
- numeric and named O-word subprograms such as `O100 call` and `O<name> call`
|
||||||
|
- canned cycles `G73`, `G81`, `G82`, `G83`, `G85`, `G86`, `G89` with `G80`, `G98`, `G99`, `L`
|
||||||
|
|
||||||
It is not the production interpreter.
|
It is not the production interpreter.
|
||||||
|
|
||||||
@@ -189,6 +193,6 @@ This matrix tracks LinuxCNC feature coverage for the web/WASM simulator. A featu
|
|||||||
| Canned cycle `G81/G80` | covered for drilling expand-to-canon path | `tests/gcode/linuxcnc_canned_cycle.ngc` |
|
| Canned cycle `G81/G80` | covered for drilling expand-to-canon path | `tests/gcode/linuxcnc_canned_cycle.ngc` |
|
||||||
| Coordinate offset Canon events | bridge-level covered | `core/tests/linuxcnc_canon_bridge_smoke.cpp` |
|
| Coordinate offset Canon events | bridge-level covered | `core/tests/linuxcnc_canon_bridge_smoke.cpp` |
|
||||||
| Cutter compensation | pending | add LinuxCNC corpus and tolerance checks |
|
| Cutter compensation | pending | add LinuxCNC corpus and tolerance checks |
|
||||||
| O-word subroutines and calls | pending | current line-by-line runner does not execute sub bodies like LinuxCNC task planner |
|
| O-word subroutines and calls | covered for numeric `O... sub/call/return/endsub` through LinuxCNC file mode; smoke parser also covers named `O<name>` sub/call/return/endsub | `tests/gcode/smoke_oword_subprogram.ngc` |
|
||||||
| Broader canned cycles `G82`-`G89` | pending | add corpus after `G81` baseline |
|
| Broader canned cycles `G73`, `G82`-`G89` | partially covered: `G73`, `G82`, `G83`, `G85`, `G86`, `G89` | `tests/gcode/linuxcnc_canned_cycles_extended.ngc`, smoke API regression |
|
||||||
| Full source-level wasm build | pending | replace Python/HAL/INI/tooldata support dependencies |
|
| Full source-level wasm build | pending | replace Python/HAL/INI/tooldata support dependencies |
|
||||||
|
|||||||
@@ -43,9 +43,12 @@ CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linux
|
|||||||
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_coolant.ngc >/tmp/cnc_sim_linuxcnc_coolant.json
|
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_coolant.ngc >/tmp/cnc_sim_linuxcnc_coolant.json
|
||||||
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_feed_modes.ngc >/tmp/cnc_sim_linuxcnc_feed_modes.json
|
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_feed_modes.ngc >/tmp/cnc_sim_linuxcnc_feed_modes.json
|
||||||
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_motion_modes.ngc >/tmp/cnc_sim_linuxcnc_motion_modes.json
|
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_motion_modes.ngc >/tmp/cnc_sim_linuxcnc_motion_modes.json
|
||||||
|
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_tool_length.ngc >/tmp/cnc_sim_linuxcnc_tool_length.json
|
||||||
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_canned_cycle.ngc >/tmp/cnc_sim_linuxcnc_canned_cycle.json
|
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_canned_cycle.ngc >/tmp/cnc_sim_linuxcnc_canned_cycle.json
|
||||||
|
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_canned_cycles_extended.ngc >/tmp/cnc_sim_linuxcnc_canned_cycles_extended.json
|
||||||
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_comments.ngc >/tmp/cnc_sim_linuxcnc_comments.json
|
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_comments.ngc >/tmp/cnc_sim_linuxcnc_comments.json
|
||||||
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_probe_no_error.ngc >/tmp/cnc_sim_linuxcnc_probe_no_error.json
|
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_probe_no_error.ngc >/tmp/cnc_sim_linuxcnc_probe_no_error.json
|
||||||
|
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/smoke_oword_subprogram.ngc >/tmp/cnc_sim_linuxcnc_oword_subprogram.json
|
||||||
cp "$base_var_file" "$var_file"
|
cp "$base_var_file" "$var_file"
|
||||||
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_coordinate_offsets.ngc >/tmp/cnc_sim_linuxcnc_coordinate_offsets.json
|
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_coordinate_offsets.ngc >/tmp/cnc_sim_linuxcnc_coordinate_offsets.json
|
||||||
cp "$base_var_file" "$var_file"
|
cp "$base_var_file" "$var_file"
|
||||||
@@ -147,6 +150,24 @@ for expected in [(2, 611, 0), (3, 612, 0), (4, 640, 0.05)]:
|
|||||||
if expected not in motion_mode_states:
|
if expected not in motion_mode_states:
|
||||||
raise SystemExit(f"missing motion mode state {expected!r}")
|
raise SystemExit(f"missing motion mode state {expected!r}")
|
||||||
|
|
||||||
|
tool_length = json.loads(Path("/tmp/cnc_sim_linuxcnc_tool_length.json").read_text())
|
||||||
|
if not any(
|
||||||
|
event["type"] == "comment" and
|
||||||
|
event["line"] == 2 and
|
||||||
|
event["reserved"] == 430 and
|
||||||
|
event["start"]["z"] == 0
|
||||||
|
for event in tool_length
|
||||||
|
):
|
||||||
|
raise SystemExit("missing G43 H1 tool length offset event")
|
||||||
|
if not any(
|
||||||
|
event["type"] == "comment" and
|
||||||
|
event["line"] == 3 and
|
||||||
|
event["reserved"] == 430 and
|
||||||
|
event["start"]["z"] == 0
|
||||||
|
for event in tool_length
|
||||||
|
):
|
||||||
|
raise SystemExit("missing G49 tool length clear event")
|
||||||
|
|
||||||
cycle = json.loads(Path("/tmp/cnc_sim_linuxcnc_canned_cycle.json").read_text())
|
cycle = json.loads(Path("/tmp/cnc_sim_linuxcnc_canned_cycle.json").read_text())
|
||||||
motions = [event for event in cycle if event["type"] in {"rapid", "linear-feed"}]
|
motions = [event for event in cycle if event["type"] in {"rapid", "linear-feed"}]
|
||||||
expected_cycle = [
|
expected_cycle = [
|
||||||
@@ -160,6 +181,38 @@ actual_cycle = [(event["type"], event["end"]["x"], event["end"]["y"], event["end
|
|||||||
if actual_cycle != expected_cycle:
|
if actual_cycle != expected_cycle:
|
||||||
raise SystemExit(f"unexpected G81/G80 expansion: {actual_cycle!r}")
|
raise SystemExit(f"unexpected G81/G80 expansion: {actual_cycle!r}")
|
||||||
|
|
||||||
|
extended_cycle = json.loads(Path("/tmp/cnc_sim_linuxcnc_canned_cycles_extended.json").read_text())
|
||||||
|
if not any(
|
||||||
|
event["type"] == "linear-feed" and
|
||||||
|
event["line"] == 3 and
|
||||||
|
event["end"]["x"] == 10 and
|
||||||
|
event["end"]["z"] == -2
|
||||||
|
for event in extended_cycle
|
||||||
|
):
|
||||||
|
raise SystemExit("missing G82 feed to bottom")
|
||||||
|
if not any(
|
||||||
|
event["type"] == "dwell" and
|
||||||
|
event["line"] == 3 and
|
||||||
|
event["dwellSeconds"] == 0.25
|
||||||
|
for event in extended_cycle
|
||||||
|
):
|
||||||
|
raise SystemExit("missing G82 dwell at bottom")
|
||||||
|
g83_feed_depths = [
|
||||||
|
event["end"]["z"]
|
||||||
|
for event in extended_cycle
|
||||||
|
if event["type"] == "linear-feed" and event["line"] == 4
|
||||||
|
]
|
||||||
|
if g83_feed_depths != [1, 0, -1, -2, -3]:
|
||||||
|
raise SystemExit(f"unexpected G83 peck depths: {g83_feed_depths!r}")
|
||||||
|
if not any(
|
||||||
|
event["type"] == "rapid" and
|
||||||
|
event["line"] == 4 and
|
||||||
|
event["end"]["x"] == 20 and
|
||||||
|
event["end"]["z"] == 2
|
||||||
|
for event in extended_cycle
|
||||||
|
):
|
||||||
|
raise SystemExit("missing G83 final retract to R plane")
|
||||||
|
|
||||||
comments = json.loads(Path("/tmp/cnc_sim_linuxcnc_comments.json").read_text())
|
comments = json.loads(Path("/tmp/cnc_sim_linuxcnc_comments.json").read_text())
|
||||||
if not any(event["type"] == "comment" and event["line"] == 2 for event in comments):
|
if not any(event["type"] == "comment" and event["line"] == 2 for event in comments):
|
||||||
raise SystemExit("missing LinuxCNC comment line event")
|
raise SystemExit("missing LinuxCNC comment line event")
|
||||||
@@ -177,6 +230,31 @@ if not any(
|
|||||||
if any(event["type"] == "linear-feed" and event["line"] == 4 for event in probe):
|
if any(event["type"] == "linear-feed" and event["line"] == 4 for event in probe):
|
||||||
raise SystemExit("G38.3 probe should not be emitted as linear-feed")
|
raise SystemExit("G38.3 probe should not be emitted as linear-feed")
|
||||||
|
|
||||||
|
oword = json.loads(Path("/tmp/cnc_sim_linuxcnc_oword_subprogram.json").read_text())
|
||||||
|
if not any(
|
||||||
|
event["type"] == "linear-feed" and
|
||||||
|
event["line"] == 8 and
|
||||||
|
event["start"]["x"] == 0 and
|
||||||
|
event["end"]["x"] == 7
|
||||||
|
for event in oword
|
||||||
|
):
|
||||||
|
raise SystemExit("missing LinuxCNC O-word expression motion")
|
||||||
|
if not any(
|
||||||
|
event["type"] == "linear-feed" and
|
||||||
|
event["line"] == 9 and
|
||||||
|
event["start"]["y"] == 0 and
|
||||||
|
event["end"]["y"] == 2
|
||||||
|
for event in oword
|
||||||
|
):
|
||||||
|
raise SystemExit("missing LinuxCNC O-word #2 argument motion")
|
||||||
|
if any(
|
||||||
|
event["type"] == "linear-feed" and
|
||||||
|
event["line"] == 11 and
|
||||||
|
event["end"]["x"] == 99
|
||||||
|
for event in oword
|
||||||
|
):
|
||||||
|
raise SystemExit("LinuxCNC O-word return should skip remaining subprogram body")
|
||||||
|
|
||||||
coords = json.loads(Path("/tmp/cnc_sim_linuxcnc_coordinate_offsets.json").read_text())
|
coords = json.loads(Path("/tmp/cnc_sim_linuxcnc_coordinate_offsets.json").read_text())
|
||||||
g5x = [event for event in coords if event["type"] == "set-g5x-offset"]
|
g5x = [event for event in coords if event["type"] == "set-g5x-offset"]
|
||||||
g92 = [event for event in coords if event["type"] == "set-g92-offset"]
|
g92 = [event for event in coords if event["type"] == "set-g92-offset"]
|
||||||
@@ -228,8 +306,11 @@ echo "dumped /tmp/cnc_sim_linuxcnc_program_stops.json"
|
|||||||
echo "dumped /tmp/cnc_sim_linuxcnc_coolant.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_coolant.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_feed_modes.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_feed_modes.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_motion_modes.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_motion_modes.json"
|
||||||
|
echo "dumped /tmp/cnc_sim_linuxcnc_tool_length.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_canned_cycle.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_canned_cycle.json"
|
||||||
|
echo "dumped /tmp/cnc_sim_linuxcnc_canned_cycles_extended.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_comments.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_comments.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_probe_no_error.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_probe_no_error.json"
|
||||||
|
echo "dumped /tmp/cnc_sim_linuxcnc_oword_subprogram.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_coordinate_offsets.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_coordinate_offsets.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_coordinate_l20.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_coordinate_l20.json"
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ CNC_SIM_RS274_VAR="$var_file" \
|
|||||||
CNC_SIM_RS274_VAR="$var_file" \
|
CNC_SIM_RS274_VAR="$var_file" \
|
||||||
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle.ngc \
|
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycle.ngc \
|
||||||
>/tmp/cnc_sim_linuxcnc_source_canned_cycle.json
|
>/tmp/cnc_sim_linuxcnc_source_canned_cycle.json
|
||||||
|
CNC_SIM_RS274_VAR="$var_file" \
|
||||||
|
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_canned_cycles_extended.ngc \
|
||||||
|
>/tmp/cnc_sim_linuxcnc_source_canned_cycles_extended.json
|
||||||
|
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
|
||||||
|
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/smoke_oword_subprogram.ngc \
|
||||||
|
>/tmp/cnc_sim_linuxcnc_source_oword_subprogram.json
|
||||||
|
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
@@ -149,9 +155,68 @@ expected_cycle = [
|
|||||||
actual_cycle = [(event["type"], event["end"]["x"], event["end"]["y"], event["end"]["z"]) for event in motions]
|
actual_cycle = [(event["type"], event["end"]["x"], event["end"]["y"], event["end"]["z"]) for event in motions]
|
||||||
if actual_cycle != expected_cycle:
|
if actual_cycle != expected_cycle:
|
||||||
raise SystemExit(f"unexpected source-linked G81/G80 expansion: {actual_cycle!r}")
|
raise SystemExit(f"unexpected source-linked G81/G80 expansion: {actual_cycle!r}")
|
||||||
|
|
||||||
|
extended_cycle = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_canned_cycles_extended.json").read_text())
|
||||||
|
if not any(
|
||||||
|
event["type"] == "linear-feed" and
|
||||||
|
event["line"] == 3 and
|
||||||
|
event["end"]["x"] == 10 and
|
||||||
|
event["end"]["z"] == -2
|
||||||
|
for event in extended_cycle
|
||||||
|
):
|
||||||
|
raise SystemExit("missing source-linked G82 feed to bottom")
|
||||||
|
if not any(
|
||||||
|
event["type"] == "dwell" and
|
||||||
|
event["line"] == 3 and
|
||||||
|
event["dwellSeconds"] == 0.25
|
||||||
|
for event in extended_cycle
|
||||||
|
):
|
||||||
|
raise SystemExit("missing source-linked G82 dwell at bottom")
|
||||||
|
g83_feed_depths = [
|
||||||
|
event["end"]["z"]
|
||||||
|
for event in extended_cycle
|
||||||
|
if event["type"] == "linear-feed" and event["line"] == 4
|
||||||
|
]
|
||||||
|
if g83_feed_depths != [1, 0, -1, -2, -3]:
|
||||||
|
raise SystemExit(f"unexpected source-linked G83 peck depths: {g83_feed_depths!r}")
|
||||||
|
if not any(
|
||||||
|
event["type"] == "rapid" and
|
||||||
|
event["line"] == 4 and
|
||||||
|
event["end"]["x"] == 20 and
|
||||||
|
event["end"]["z"] == 2
|
||||||
|
for event in extended_cycle
|
||||||
|
):
|
||||||
|
raise SystemExit("missing source-linked G83 final retract to R plane")
|
||||||
|
|
||||||
|
oword = json.loads(Path("/tmp/cnc_sim_linuxcnc_source_oword_subprogram.json").read_text())
|
||||||
|
if not any(
|
||||||
|
event["type"] == "linear-feed" and
|
||||||
|
event["line"] == 8 and
|
||||||
|
event["start"]["x"] == 0 and
|
||||||
|
event["end"]["x"] == 7
|
||||||
|
for event in oword
|
||||||
|
):
|
||||||
|
raise SystemExit("missing source-linked O-word expression motion")
|
||||||
|
if not any(
|
||||||
|
event["type"] == "linear-feed" and
|
||||||
|
event["line"] == 9 and
|
||||||
|
event["start"]["y"] == 0 and
|
||||||
|
event["end"]["y"] == 2
|
||||||
|
for event in oword
|
||||||
|
):
|
||||||
|
raise SystemExit("missing source-linked O-word #2 argument motion")
|
||||||
|
if any(
|
||||||
|
event["type"] == "linear-feed" and
|
||||||
|
event["line"] == 11 and
|
||||||
|
event["end"]["x"] == 99
|
||||||
|
for event in oword
|
||||||
|
):
|
||||||
|
raise SystemExit("source-linked O-word return should skip remaining subprogram body")
|
||||||
PY
|
PY
|
||||||
|
|
||||||
echo "linuxcnc rs274 source link smoke passed (${#objects[@]} local objects)"
|
echo "linuxcnc rs274 source link smoke passed (${#objects[@]} local objects)"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_source_basic_mill.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_source_basic_mill.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_source_rtcp_controls.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_source_rtcp_controls.json"
|
||||||
echo "dumped /tmp/cnc_sim_linuxcnc_source_canned_cycle.json"
|
echo "dumped /tmp/cnc_sim_linuxcnc_source_canned_cycle.json"
|
||||||
|
echo "dumped /tmp/cnc_sim_linuxcnc_source_canned_cycles_extended.json"
|
||||||
|
echo "dumped /tmp/cnc_sim_linuxcnc_source_oword_subprogram.json"
|
||||||
|
|||||||
@@ -51,7 +51,11 @@ mkdir -p "$build_dir"
|
|||||||
"$build_dir/cnc_sim_api_smoke"
|
"$build_dir/cnc_sim_api_smoke"
|
||||||
"$build_dir/cnc_sim_dump" tests/gcode/basic_mill.ngc >/tmp/cnc_sim_basic_mill.json
|
"$build_dir/cnc_sim_dump" tests/gcode/basic_mill.ngc >/tmp/cnc_sim_basic_mill.json
|
||||||
"$build_dir/cnc_sim_dump" tests/gcode/incremental_and_r_arc.ngc >/tmp/cnc_sim_incremental_and_r_arc.json
|
"$build_dir/cnc_sim_dump" tests/gcode/incremental_and_r_arc.ngc >/tmp/cnc_sim_incremental_and_r_arc.json
|
||||||
|
"$build_dir/cnc_sim_dump" tests/gcode/smoke_subprogram_m98.ngc >/tmp/cnc_sim_smoke_subprogram_m98.json
|
||||||
|
"$build_dir/cnc_sim_dump" tests/gcode/smoke_oword_subprogram.ngc >/tmp/cnc_sim_smoke_oword_subprogram.json
|
||||||
|
|
||||||
echo "native tests passed"
|
echo "native tests passed"
|
||||||
echo "dumped /tmp/cnc_sim_basic_mill.json"
|
echo "dumped /tmp/cnc_sim_basic_mill.json"
|
||||||
echo "dumped /tmp/cnc_sim_incremental_and_r_arc.json"
|
echo "dumped /tmp/cnc_sim_incremental_and_r_arc.json"
|
||||||
|
echo "dumped /tmp/cnc_sim_smoke_subprogram_m98.json"
|
||||||
|
echo "dumped /tmp/cnc_sim_smoke_oword_subprogram.json"
|
||||||
|
|||||||
6
tests/gcode/linuxcnc_canned_cycles_extended.ngc
Normal file
6
tests/gcode/linuxcnc_canned_cycles_extended.ngc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
G21 G90 G17
|
||||||
|
G0 X0 Y0 Z10
|
||||||
|
G99 G82 X10 Y0 Z-2 R3 P0.25 F100
|
||||||
|
G83 X20 Y0 Z-3 R2 Q1
|
||||||
|
G80
|
||||||
|
M30
|
||||||
4
tests/gcode/linuxcnc_tool_length.ngc
Normal file
4
tests/gcode/linuxcnc_tool_length.ngc
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
G21 G90 G17
|
||||||
|
G43 H1
|
||||||
|
G49 G0 X0
|
||||||
|
M30
|
||||||
12
tests/gcode/smoke_oword_subprogram.ngc
Normal file
12
tests/gcode/smoke_oword_subprogram.ngc
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
G21 G90
|
||||||
|
G0 X0 Y0 Z0
|
||||||
|
F100
|
||||||
|
O100 call [2 + 3] [8 / 4]
|
||||||
|
G1 X20
|
||||||
|
M30
|
||||||
|
O100 sub
|
||||||
|
G1 X[#1 + #2]
|
||||||
|
G1 Y#2
|
||||||
|
O100 return
|
||||||
|
G1 X99
|
||||||
|
O100 endsub
|
||||||
10
tests/gcode/smoke_subprogram_m98.ngc
Normal file
10
tests/gcode/smoke_subprogram_m98.ngc
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
G21 G90
|
||||||
|
G0 X0 Y0 Z0
|
||||||
|
F100
|
||||||
|
M98 P100 L2
|
||||||
|
G1 X20
|
||||||
|
M30
|
||||||
|
O100
|
||||||
|
G91 G1 X5
|
||||||
|
G90
|
||||||
|
M99
|
||||||
Reference in New Issue
Block a user