按建议,继续完成后续工作

结论:将 Interp::synch() 当前/选中工具槽位读取接入 standalone tool adapter,并补充 native 验证。
This commit is contained in:
2026-06-08 00:02:15 +08:00
parent 335ab61a61
commit bdbe246a82
8 changed files with 57 additions and 10 deletions

View File

@@ -8,6 +8,7 @@
#include <unistd.h>
#include "canon_event_sink.hh"
#include "linuxcnc_tool_adapter.hh"
#include "nml_intf/emc.hh"
namespace {
@@ -31,6 +32,7 @@ int main()
std::filesystem::current_path(temp_dir);
emcStatus->motion.traj.linearUnits = 1.0;
standalone::reset_tool_adapter();
Interp interp;
standalone::reset_canon_events();
@@ -47,6 +49,7 @@ int main()
}
emcStatus->motion.traj.linearUnits = 1.0 / 25.4;
standalone::reset_tool_adapter();
Interp inch_interp;
standalone::reset_canon_events();
const int inch_rc = inch_interp.init();
@@ -60,7 +63,24 @@ int main()
std::cout << "inch_canon_event=" << event << "\n";
}
standalone::reset_tool_adapter();
CANON_TOOL_TABLE tool = standalone::tool_entry_init();
tool.toolno = 2;
tool.pocketno = 2;
standalone::set_tool_entry(2, tool);
standalone::select_tool(2);
standalone::change_selected_tool();
Interp synch_interp;
const int synch_rc = synch_interp.synch();
std::cout << "synch=" << synch_rc << "\n";
std::cout << "synch.current_pocket=" << synch_interp._setup.current_pocket << "\n";
std::cout << "synch.selected_pocket=" << synch_interp._setup.selected_pocket << "\n";
std::cout << "synch.tool_0=" << synch_interp._setup.tool_table[0].toolno << "\n";
std::cout << "synch.tool_2=" << synch_interp._setup.tool_table[2].toolno << "\n";
emcStatus->motion.traj.linearUnits = 1.0;
standalone::reset_tool_adapter();
std::filesystem::remove_all(temp_dir);
return (rc == INTERP_OK && inch_rc == INTERP_OK) ? 0 : 1;
return (rc == INTERP_OK && inch_rc == INTERP_OK && synch_rc == INTERP_OK) ? 0 : 1;
}

View File

@@ -505,8 +505,8 @@ double GET_EXTERNAL_TOOL_LENGTH_COFFSET() { return 0.0; }
double GET_EXTERNAL_TOOL_LENGTH_UOFFSET() { return 0.0; }
double GET_EXTERNAL_TOOL_LENGTH_VOFFSET() { return 0.0; }
double GET_EXTERNAL_TOOL_LENGTH_WOFFSET() { return 0.0; }
int GET_EXTERNAL_TOOL_SLOT() { return 0; }
int GET_EXTERNAL_SELECTED_TOOL_SLOT() { return -1; }
int GET_EXTERNAL_TOOL_SLOT() { return standalone::current_tool_index(); }
int GET_EXTERNAL_SELECTED_TOOL_SLOT() { return standalone::selected_tool_index(); }
CANON_TOOL_TABLE GET_EXTERNAL_TOOL_TABLE(int index)
{
CANON_TOOL_TABLE tool = standalone::tool_entry_init();

View File

@@ -10,12 +10,18 @@ std::array<CANON_TOOL_TABLE, CANON_POCKETS_MAX> &tool_table()
return tools;
}
int &selected_tool_index()
int &selected_tool_index_ref()
{
static int index = -1;
return index;
}
int &current_tool_index_ref()
{
static int index = 0;
return index;
}
CANON_TOOL_TABLE empty_tool()
{
CANON_TOOL_TABLE tool{};
@@ -30,7 +36,8 @@ namespace standalone {
void reset_tool_adapter()
{
selected_tool_index() = -1;
selected_tool_index_ref() = -1;
current_tool_index_ref() = 0;
auto &tools = tool_table();
for (int index = 0; index < CANON_POCKETS_MAX; ++index) {
tools[index] = empty_tool();
@@ -76,9 +83,19 @@ int get_tool_entry(CANON_TOOL_TABLE *tool, int index)
return 0;
}
int current_tool_index()
{
return current_tool_index_ref();
}
int selected_tool_index()
{
return selected_tool_index_ref();
}
void select_tool(int toolno)
{
selected_tool_index() = find_tool_index_for_tool(toolno);
selected_tool_index_ref() = find_tool_index_for_tool(toolno);
}
void change_tool_number(int index)
@@ -91,11 +108,12 @@ void change_tool_number(int index)
CANON_TOOL_TABLE spindle_tool = tools[index];
spindle_tool.pocketno = 0;
tools[0] = spindle_tool;
current_tool_index_ref() = index;
}
void change_selected_tool()
{
change_tool_number(selected_tool_index());
change_tool_number(selected_tool_index_ref());
}
} // namespace standalone

View File

@@ -9,6 +9,8 @@ void set_tool_entry(int index, const CANON_TOOL_TABLE &tool);
CANON_TOOL_TABLE tool_entry_init();
int find_tool_index_for_tool(int toolno);
int get_tool_entry(CANON_TOOL_TABLE *tool, int index);
int current_tool_index();
int selected_tool_index();
void select_tool(int toolno);
void change_selected_tool();
void change_tool_number(int index);