按规划持续工作
结论:扩展 5axis native remap 执行验证,使用 vendored LinuxCNC demo 文件 xyzac_switchkins_test_1.ngc 和 xyzac_switchkins_test_3.ngc 走 open/read/execute 文件路径,并确认 remap 同步边界与 _hal[motion.switchkins-type] 最终状态。
This commit is contained in:
@@ -26,6 +26,12 @@ struct MachineCase {
|
||||
const char *ini_rel;
|
||||
};
|
||||
|
||||
struct DemoCase {
|
||||
const char *label;
|
||||
const char *rel;
|
||||
double expected_switchkins;
|
||||
};
|
||||
|
||||
std::filesystem::path vendor_path(const std::string &rel)
|
||||
{
|
||||
return std::filesystem::path(LINUXCNC_VENDOR_DIR) / rel;
|
||||
@@ -145,6 +151,84 @@ bool execute_step(Interp &interp, const std::string &label, const char *command,
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool execute_demo_file(const MachineCase &machine, const DemoCase &demo)
|
||||
{
|
||||
Interp interp;
|
||||
initialize_interp(interp);
|
||||
|
||||
const std::string label = std::string(machine.label) + "_" + demo.label;
|
||||
bool ok = parse_machine_remaps(interp, machine);
|
||||
|
||||
const auto file_path = vendor_path(demo.rel);
|
||||
const int open_rc = interp.open(file_path.c_str());
|
||||
std::cout << label << "_file_open=" << open_rc << "\n";
|
||||
if (open_rc != INTERP_OK) {
|
||||
print_bool(label + "_linuxcnc_demo_file_execute", false);
|
||||
return false;
|
||||
}
|
||||
|
||||
int read_count = 0;
|
||||
int execute_count = 0;
|
||||
int finish_count = 0;
|
||||
int final_rc = INTERP_OK;
|
||||
bool reached_exit = false;
|
||||
|
||||
while (read_count < 512 && execute_count < 512) {
|
||||
const int read_rc = interp.read();
|
||||
if (read_rc == INTERP_ENDFILE) {
|
||||
std::cout << label << "_file_read_eof=" << read_rc << "\n";
|
||||
final_rc = read_rc;
|
||||
break;
|
||||
}
|
||||
|
||||
++read_count;
|
||||
std::cout << label << "_file_read_" << read_count << "=" << read_rc << "\n";
|
||||
if ((read_rc != INTERP_OK) && (read_rc != INTERP_EXECUTE_FINISH)) {
|
||||
final_rc = read_rc;
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if ((execute_rc != INTERP_OK) && (execute_rc != INTERP_EXIT)) {
|
||||
if (execute_rc != INTERP_EXECUTE_FINISH) {
|
||||
ok = false;
|
||||
final_rc = execute_rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (execute_rc == INTERP_EXIT) {
|
||||
reached_exit = true;
|
||||
final_rc = execute_rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << label << "_file_read_count=" << read_count << "\n";
|
||||
std::cout << label << "_file_execute_count=" << execute_count << "\n";
|
||||
std::cout << label << "_file_finish_count=" << finish_count << "\n";
|
||||
std::cout << label << "_file_final_rc=" << final_rc << "\n";
|
||||
print_bool(label + "_file_reached_exit", reached_exit);
|
||||
|
||||
ok &= reached_exit;
|
||||
ok &= read_count > 0;
|
||||
ok &= execute_count > 0;
|
||||
ok &= read_count < 512;
|
||||
ok &= execute_count < 512;
|
||||
ok &= read_hal_named(interp, label, "_hal[motion.switchkins-type]",
|
||||
demo.expected_switchkins);
|
||||
|
||||
print_bool(label + "_linuxcnc_demo_file_execute", ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool check_machine(const MachineCase &machine)
|
||||
{
|
||||
Interp interp;
|
||||
@@ -181,6 +265,25 @@ int main()
|
||||
ok &= check_machine(machine);
|
||||
}
|
||||
|
||||
const DemoCase demos[] = {
|
||||
{
|
||||
"xyzac_switchkins_test_1",
|
||||
"configs/sim/axis/vismach/5axis/table-rotary-tilting/demos/"
|
||||
"xyzac_switchkins_test_1.ngc",
|
||||
0.0,
|
||||
},
|
||||
{
|
||||
"xyzac_switchkins_test_3",
|
||||
"configs/sim/axis/vismach/5axis/table-rotary-tilting/demos/"
|
||||
"xyzac_switchkins_test_3.ngc",
|
||||
0.0,
|
||||
},
|
||||
};
|
||||
|
||||
for (const auto &demo : demos) {
|
||||
ok &= execute_demo_file(cases[0], demo);
|
||||
}
|
||||
|
||||
print_bool("fiveaxis_linuxcnc_remap_execute_path", ok);
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user