按建议继续完成后续工作
结论:native 兼容性验证已接入 interpreter init、rotary indexer、canonical 边界 fixture,并新增 upstream rs274 side-by-side 基线;完整 verify_native_probes.sh 已通过。
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#define private public
|
||||
#include "emc/rs274ngc/rs274ngc_interp.hh"
|
||||
#undef private
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "canon_event_sink.hh"
|
||||
#include "linuxcnc_hal_adapter.hh"
|
||||
#include "linuxcnc_tool_adapter.hh"
|
||||
|
||||
namespace {
|
||||
|
||||
void initialize_indexer_interp(Interp &interp)
|
||||
{
|
||||
standalone::reset_hal_adapter();
|
||||
standalone::reset_tool_adapter();
|
||||
|
||||
interp._setup.length_units = CANON_UNITS_MM;
|
||||
interp._setup.distance_mode = DISTANCE_MODE::ABSOLUTE;
|
||||
interp._setup.ijk_distance_mode = DISTANCE_MODE::ABSOLUTE;
|
||||
interp._setup.feed_mode = FEED_MODE::UNITS_PER_MINUTE;
|
||||
interp._setup.plane = CANON_PLANE::XY;
|
||||
interp._setup.motion_mode = G_0;
|
||||
interp._setup.percent_flag = false;
|
||||
interp._setup.sequence_number = 1;
|
||||
interp._setup.parameter_occurrence = 0;
|
||||
interp._setup.num_spindles = 1;
|
||||
interp._setup.a_indexer_jnum = 0;
|
||||
interp._setup.parameters[5599] = 1.0;
|
||||
std::memcpy(interp._readers, Interp::default_readers, sizeof(Interp::default_readers));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
Interp interp;
|
||||
standalone::reset_canon_events();
|
||||
initialize_indexer_interp(interp);
|
||||
|
||||
const int rc = interp.execute("G0 A90\n");
|
||||
std::cout << "execute=" << rc << "\n";
|
||||
std::cout << "post_a=" << interp._setup.AA_current << "\n";
|
||||
std::cout << "canon_event_count=" << standalone::canon_events().size() << "\n";
|
||||
for (const auto &event : standalone::canon_events()) {
|
||||
std::cout << "canon_event=" << event << "\n";
|
||||
}
|
||||
|
||||
return rc == INTERP_OK ? 0 : 1;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#define private public
|
||||
#include "emc/rs274ngc/rs274ngc_interp.hh"
|
||||
#undef private
|
||||
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "canon_event_sink.hh"
|
||||
|
||||
namespace {
|
||||
|
||||
std::filesystem::path make_temp_dir()
|
||||
{
|
||||
std::string pattern = "/tmp/linuxcnc-init-XXXXXX";
|
||||
char *path = mkdtemp(pattern.data());
|
||||
if (path == nullptr) {
|
||||
std::perror("mkdtemp");
|
||||
std::exit(2);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
const auto temp_dir = make_temp_dir();
|
||||
std::filesystem::current_path(temp_dir);
|
||||
|
||||
Interp interp;
|
||||
standalone::reset_canon_events();
|
||||
|
||||
const int rc = interp.init();
|
||||
std::cout << "init=" << rc << "\n";
|
||||
std::cout << "setup.length_units=" << static_cast<int>(interp._setup.length_units) << "\n";
|
||||
std::cout << "setup.origin_index=" << interp._setup.origin_index << "\n";
|
||||
std::cout << "setup.distance_mode=" << static_cast<int>(interp._setup.distance_mode) << "\n";
|
||||
std::cout << "setup.feed_mode=" << static_cast<int>(interp._setup.feed_mode) << "\n";
|
||||
std::cout << "setup.motion_mode=" << interp._setup.motion_mode << "\n";
|
||||
std::cout << "canon_event_count=" << standalone::canon_events().size() << "\n";
|
||||
for (const auto &event : standalone::canon_events()) {
|
||||
std::cout << "canon_event=" << event << "\n";
|
||||
}
|
||||
|
||||
std::filesystem::remove_all(temp_dir);
|
||||
return rc == INTERP_OK ? 0 : 1;
|
||||
}
|
||||
@@ -36,8 +36,8 @@ const std::vector<std::string> &canon_events()
|
||||
} // namespace standalone
|
||||
|
||||
bool GET_BLOCK_DELETE(void) { return false; }
|
||||
void FINISH(void) {}
|
||||
void ON_RESET(void) {}
|
||||
void FINISH(void) { standalone::push_canon_event("FINISH"); }
|
||||
void ON_RESET(void) { standalone::push_canon_event("ON_RESET"); }
|
||||
|
||||
USER_DEFINED_FUNCTION_TYPE USER_DEFINED_FUNCTION[USER_DEFINED_FUNCTION_NUM] = {};
|
||||
|
||||
@@ -50,7 +50,7 @@ int USER_DEFINED_FUNCTION_ADD(USER_DEFINED_FUNCTION_TYPE func, int num)
|
||||
return num;
|
||||
}
|
||||
|
||||
void INIT_CANON() {}
|
||||
void INIT_CANON() { standalone::push_canon_event("INIT_CANON"); }
|
||||
void SET_G5X_OFFSET(int index,
|
||||
double x, double y, double z,
|
||||
double a, double b, double c,
|
||||
@@ -307,7 +307,7 @@ void CHANGE_TOOL_NUMBER(int pocket)
|
||||
oss << "CHANGE_TOOL_NUMBER pocket=" << pocket;
|
||||
standalone::push_canon_event(oss.str());
|
||||
}
|
||||
void RELOAD_TOOLDATA(void) {}
|
||||
void RELOAD_TOOLDATA(void) { standalone::push_canon_event("RELOAD_TOOLDATA"); }
|
||||
void CLAMP_AXIS(CANON_AXIS) {}
|
||||
void DISABLE_ADAPTIVE_FEED() { standalone::push_canon_event("DISABLE_ADAPTIVE_FEED"); }
|
||||
void ENABLE_ADAPTIVE_FEED() { standalone::push_canon_event("ENABLE_ADAPTIVE_FEED"); }
|
||||
@@ -390,15 +390,52 @@ int WAIT(int index, int input_type, int wait_type, double timeout)
|
||||
standalone::push_canon_event(oss.str());
|
||||
return 0;
|
||||
}
|
||||
int UNLOCK_ROTARY(int, int) { return 0; }
|
||||
int LOCK_ROTARY(int, int) { return 0; }
|
||||
void UPDATE_TAG(const StateTag &) {}
|
||||
int UNLOCK_ROTARY(int line_no, int joint_num)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "UNLOCK_ROTARY line=" << line_no << " joint=" << joint_num;
|
||||
standalone::push_canon_event(oss.str());
|
||||
return 0;
|
||||
}
|
||||
int LOCK_ROTARY(int line_no, int joint_num)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "LOCK_ROTARY line=" << line_no << " joint=" << joint_num;
|
||||
standalone::push_canon_event(oss.str());
|
||||
return 0;
|
||||
}
|
||||
void UPDATE_TAG(const StateTag &tag)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "UPDATE_TAG"
|
||||
<< " line=" << tag.fields[GM_FIELD_LINE_NUMBER]
|
||||
<< " g0=" << tag.fields[GM_FIELD_G_MODE_0]
|
||||
<< " motion=" << tag.fields[GM_FIELD_MOTION_MODE]
|
||||
<< " plane=" << tag.fields[GM_FIELD_PLANE]
|
||||
<< " origin=" << tag.fields[GM_FIELD_ORIGIN]
|
||||
<< " feed=" << tag.fields_float[GM_FIELD_FLOAT_FEED]
|
||||
<< " speed=" << tag.fields_float[GM_FIELD_FLOAT_SPEED]
|
||||
<< " flags=" << tag.flags.to_ulong();
|
||||
standalone::push_canon_event(oss.str());
|
||||
}
|
||||
|
||||
void MESSAGE(char *s) { standalone::push_canon_event(std::string("MESSAGE: ") + (s ? s : "")); }
|
||||
void LOG(char *) {}
|
||||
void LOGOPEN(char *) {}
|
||||
void LOGAPPEND(char *) {}
|
||||
void LOGCLOSE() {}
|
||||
void LOG(char *s)
|
||||
{
|
||||
standalone::push_canon_event(std::string("LOG: ") + (s ? s : ""));
|
||||
}
|
||||
void LOGOPEN(char *s)
|
||||
{
|
||||
standalone::push_canon_event(std::string("LOGOPEN: ") + (s ? s : ""));
|
||||
}
|
||||
void LOGAPPEND(char *s)
|
||||
{
|
||||
standalone::push_canon_event(std::string("LOGAPPEND: ") + (s ? s : ""));
|
||||
}
|
||||
void LOGCLOSE()
|
||||
{
|
||||
standalone::push_canon_event("LOGCLOSE");
|
||||
}
|
||||
|
||||
void CANON_ERROR(const char *fmt, ...)
|
||||
{
|
||||
|
||||
@@ -187,9 +187,9 @@ setup::setup()
|
||||
a_axis_wrapped(0),
|
||||
b_axis_wrapped(0),
|
||||
c_axis_wrapped(0),
|
||||
a_indexer_jnum(0),
|
||||
b_indexer_jnum(0),
|
||||
c_indexer_jnum(0),
|
||||
a_indexer_jnum(-1),
|
||||
b_indexer_jnum(-1),
|
||||
c_indexer_jnum(-1),
|
||||
lathe_diameter_mode(0),
|
||||
mdi_interrupt(0),
|
||||
feature_set(0),
|
||||
|
||||
Reference in New Issue
Block a user