按规划持续工作

结论:五轴 switchkins remap native 执行路径已扩展到 vendored xyzac/xyzbc switchkins demo,验证仍通过 LinuxCNC REMAP/O-word/open/read/execute 路径和 HAL adapter 边界完成,未新增自写 M428/M429/M430 或运动学语义。
This commit is contained in:
2026-06-08 17:52:03 +08:00
parent 68a0a2db22
commit 567f72d35f
5 changed files with 66 additions and 19 deletions

View File

@@ -42,6 +42,18 @@ void print_bool(const std::string &name, bool value)
std::cout << name << "=" << (value ? 1 : 0) << "\n";
}
void print_interp_error(Interp &interp, const std::string &label, int rc)
{
char error_buf[LINELEN] = {0};
interp.error_text(rc, error_buf, sizeof(error_buf));
std::cout << label << "_error_text=" << error_buf << "\n";
std::cout << label << "_sequence_number=" << interp._setup.sequence_number << "\n";
std::cout << label << "_linetext=" << interp._setup.linetext << "\n";
std::cout << label << "_blocktext=" << interp._setup.blocktext << "\n";
}
constexpr int kMaxDemoFileSteps = 4096;
void seed_switchkins_hal()
{
standalone::reset_hal_adapter();
@@ -63,7 +75,7 @@ void initialize_interp(Interp &interp)
interp._setup.length_units = CANON_UNITS_MM;
interp._setup.distance_mode = DISTANCE_MODE::ABSOLUTE;
interp._setup.ijk_distance_mode = DISTANCE_MODE::ABSOLUTE;
interp._setup.ijk_distance_mode = DISTANCE_MODE::INCREMENTAL;
interp._setup.feed_mode = FEED_MODE::UNITS_PER_MINUTE;
interp._setup.plane = CANON_PLANE::XY;
interp._setup.motion_mode = G_0;
@@ -173,7 +185,7 @@ bool execute_demo_file(const MachineCase &machine, const DemoCase &demo)
int final_rc = INTERP_OK;
bool reached_exit = false;
while (read_count < 512 && execute_count < 512) {
while (read_count < kMaxDemoFileSteps && execute_count < kMaxDemoFileSteps) {
const int read_rc = interp.read();
if (read_rc == INTERP_ENDFILE) {
std::cout << label << "_file_read_eof=" << read_rc << "\n";
@@ -182,8 +194,9 @@ bool execute_demo_file(const MachineCase &machine, const DemoCase &demo)
}
++read_count;
std::cout << label << "_file_read_" << read_count << "=" << read_rc << "\n";
if ((read_rc != INTERP_OK) && (read_rc != INTERP_EXECUTE_FINISH)) {
std::cout << label << "_file_read_" << read_count << "=" << read_rc << "\n";
print_interp_error(interp, label + "_file_read", read_rc);
final_rc = read_rc;
ok = false;
break;
@@ -191,7 +204,6 @@ bool execute_demo_file(const MachineCase &machine, const DemoCase &demo)
int execute_rc = interp.execute();
++execute_count;
std::cout << label << "_file_execute_" << execute_count << "=" << execute_rc << "\n";
final_rc = execute_rc;
if (execute_rc == INTERP_EXECUTE_FINISH) {
++finish_count;
@@ -199,6 +211,9 @@ bool execute_demo_file(const MachineCase &machine, const DemoCase &demo)
if ((execute_rc != INTERP_OK) && (execute_rc != INTERP_EXIT)) {
if (execute_rc != INTERP_EXECUTE_FINISH) {
std::cout << label << "_file_execute_" << execute_count << "="
<< execute_rc << "\n";
print_interp_error(interp, label + "_file_execute", execute_rc);
ok = false;
final_rc = execute_rc;
break;
@@ -220,8 +235,8 @@ bool execute_demo_file(const MachineCase &machine, const DemoCase &demo)
ok &= reached_exit;
ok &= read_count > 0;
ok &= execute_count > 0;
ok &= read_count < 512;
ok &= execute_count < 512;
ok &= read_count < kMaxDemoFileSteps;
ok &= execute_count < kMaxDemoFileSteps;
ok &= read_hal_named(interp, label, "_hal[motion.switchkins-type]",
demo.expected_switchkins);
@@ -266,6 +281,18 @@ int main()
}
const DemoCase demos[] = {
{
"xyzac_switchkins",
"configs/sim/axis/vismach/5axis/table-rotary-tilting/demos/"
"xyzac_switchkins.ngc",
0.0,
},
{
"xyzbc_switchkins",
"configs/sim/axis/vismach/5axis/table-rotary-tilting/demos/"
"xyzbc_switchkins.ngc",
0.0,
},
{
"xyzac_switchkins_test_1",
"configs/sim/axis/vismach/5axis/table-rotary-tilting/demos/"
@@ -280,9 +307,10 @@ int main()
},
};
for (const auto &demo : demos) {
ok &= execute_demo_file(cases[0], demo);
}
ok &= execute_demo_file(cases[0], demos[0]);
ok &= execute_demo_file(cases[1], demos[1]);
ok &= execute_demo_file(cases[0], demos[2]);
ok &= execute_demo_file(cases[0], demos[3]);
print_bool("fiveaxis_linuxcnc_remap_execute_path", ok);
return ok ? 0 : 1;