Skip to content

Commit

Permalink
remove tool argument from CHANGE_TOOL()
Browse files Browse the repository at this point in the history
  • Loading branch information
rene-dev committed Sep 27, 2023
1 parent 43fed4a commit c5412d5
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 35 deletions.
6 changes: 3 additions & 3 deletions nc_files/remap_lib/python-stdglue/stdglue.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def change_epilog(self, **words):
if self.return_value > 0.0:
# commit change
self.selected_pocket = int(self.params["selected_pocket"])
emccanon.CHANGE_TOOL(self.selected_pocket)
emccanon.CHANGE_TOOL()
self.current_pocket = self.selected_pocket
self.selected_pocket = -1
self.selected_tool = -1
Expand Down Expand Up @@ -476,7 +476,7 @@ def index_lathe_tool_with_wear(self,**words):
# change tool
try:
self.selected_pocket = int(self.params["selected_pocket"])
emccanon.CHANGE_TOOL(self.selected_pocket)
emccanon.CHANGE_TOOL()
self.current_pocket = self.selected_pocket
self.selected_pocket = -1
self.selected_tool = -1
Expand Down Expand Up @@ -572,7 +572,7 @@ def tool_probe_m6(self, **words):

try:
self.selected_pocket = int(self.params["selected_pocket"])
emccanon.CHANGE_TOOL(self.selected_pocket)
emccanon.CHANGE_TOOL()
self.current_pocket = self.selected_pocket
self.selected_pocket = -1
self.selected_tool = -1
Expand Down
5 changes: 1 addition & 4 deletions src/emc/canterp/canterp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,7 @@ int Canterp::execute(const char *line) {
}

if (!strcmp(the_command_name, "CHANGE_TOOL")) {
if (1 != sscanf(the_command_args, "%d", &i1)) {
return INTERP_ERROR;
}
CHANGE_TOOL(i1);
CHANGE_TOOL();
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/emc/nml_intf/canon.hh
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ extern void SET_TOOL_TABLE_ENTRY(int pocket, int toolno, EmcPose offset, double
double frontangle, double backangle, int orientation);
extern void USE_TOOL_LENGTH_OFFSET(EmcPose offset);

extern void CHANGE_TOOL(int slot); /* slot is slot number */
extern void CHANGE_TOOL();

/* It is assumed that each cutting tool in the machine is assigned to a
slot (intended to correspond to a slot number in a tool carousel).
Expand Down
7 changes: 4 additions & 3 deletions src/emc/rs274ngc/gcodemodule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ static PyTypeObject LineCodeType = {
static PyObject *callback;
static int interp_error;
static int last_sequence_number;
static int selected_tool = 0;
static bool metric;
static double _pos_x, _pos_y, _pos_z, _pos_a, _pos_b, _pos_c, _pos_u, _pos_v, _pos_w;
EmcPose tool_offset;
Expand Down Expand Up @@ -427,11 +428,11 @@ void SET_FEED_MODE(int spindle, int mode) {
#endif
}

void CHANGE_TOOL(int pocket) {
void CHANGE_TOOL() {
maybe_new_line();
if(interp_error) return;
PyObject *result =
callmethod(callback, "change_tool", "i", pocket);
callmethod(callback, "change_tool", "i", selected_tool);
if(result == NULL) interp_error ++;
Py_XDECREF(result);
}
Expand Down Expand Up @@ -528,7 +529,7 @@ void PROGRAM_END() {}
void FINISH() {}
void ON_RESET() {}
void PALLET_SHUTTLE() {}
void SELECT_TOOL(int tool) {}
void SELECT_TOOL(int tool) {selected_tool = tool;}
void UPDATE_TAG(StateTag tag) {}
void OPTIONAL_PROGRAM_STOP() {}
int GET_EXTERNAL_TC_FAULT() {return 0;}
Expand Down
2 changes: 1 addition & 1 deletion src/emc/rs274ngc/interp_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6149,7 +6149,7 @@ int Interp::convert_tool_change(setup_pointer settings) //!< pointer to machine
settings->w_current = w_end;
}

CHANGE_TOOL(settings->selected_pocket);
CHANGE_TOOL();

settings->current_pocket = settings->selected_pocket;
// tool change can move the controlled point. reread it:
Expand Down
14 changes: 9 additions & 5 deletions src/emc/sai/saicanon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,15 @@ void USE_TOOL_LENGTH_OFFSET(EmcPose offset)
offset.tran.x, offset.tran.y, offset.tran.z, offset.a, offset.b, offset.c, offset.u, offset.v, offset.w);
}

void CHANGE_TOOL(int slot)
void CHANGE_TOOL()
{
PRINT("CHANGE_TOOL(%d)\n", slot);
_sai._active_slot = slot;
PRINT("CHANGE_TOOL()\n");
_sai._active_slot = _sai._selected_tool;
#ifdef TOOL_NML //{
_sai._tools[0] = _sai._tools[slot];
#else //}{
CANON_TOOL_TABLE tdata;
if (tooldata_get(&tdata,slot) != IDX_OK) {
if (tooldata_get(&tdata,_sai._selected_tool) != IDX_OK) {
UNEXPECTED_MSG;
}
_sai._tools[0] = tdata;
Expand All @@ -571,7 +571,10 @@ void CHANGE_TOOL(int slot)
}

void SELECT_TOOL(int tool)//TODO: fix slot number
{PRINT("SELECT_TOOL(%d)\n", tool);}
{
PRINT("SELECT_TOOL(%d)\n", tool);
_sai._selected_tool = tool;
}

void CHANGE_TOOL_NUMBER(int tool)
{
Expand Down Expand Up @@ -1136,6 +1139,7 @@ void reset_internals()
StandaloneInterpInternals::StandaloneInterpInternals() :
_active_plane(CANON_PLANE::XY),
_active_slot(1),
_selected_tool(0),
_feed_mode(0),
_feed_rate(0.0),
_flood(0),
Expand Down
1 change: 1 addition & 0 deletions src/emc/sai/saicanon.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct StandaloneInterpInternals

CANON_PLANE _active_plane;
int _active_slot;
int _selected_tool;
int _feed_mode;
double _feed_rate;
int _flood;
Expand Down
2 changes: 1 addition & 1 deletion src/emc/task/emccanon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2900,7 +2900,7 @@ void USE_TOOL_LENGTH_OFFSET(EmcPose offset)
}

/* CHANGE_TOOL results from M6 */
void CHANGE_TOOL(int slot)
void CHANGE_TOOL()
{
EMC_TRAJ_LINEAR_MOVE linearMoveMsg;
linearMoveMsg.feed_mode = canon.feed_mode;
Expand Down
8 changes: 4 additions & 4 deletions tests/ccomp/lathe-comp/expected
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
N..... SELECT_TOOL(0)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(0)
N..... CHANGE_TOOL()
N..... STRAIGHT_TRAVERSE(0.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... COMMENT("interpreter: cutter radius compensation off")
N..... STRAIGHT_FEED(0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
Expand All @@ -24,7 +24,7 @@
N..... STRAIGHT_TRAVERSE(0.3000, 0.0000, 1.7500, 0.0000, 0.0000, 0.0000)
N..... SELECT_TOOL(2)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(2)
N..... CHANGE_TOOL()
N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
N..... STRAIGHT_TRAVERSE(0.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... COMMENT("interpreter: cutter radius compensation on left")
Expand All @@ -38,7 +38,7 @@
N..... STRAIGHT_TRAVERSE(0.3000, 0.0000, 1.7500, 0.0000, 0.0000, 0.0000)
N..... SELECT_TOOL(7)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(7)
N..... CHANGE_TOOL()
N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
N..... STRAIGHT_TRAVERSE(0.3000, 0.0000, 1.8500, 0.0000, 0.0000, 0.0000)
N..... STRAIGHT_TRAVERSE(-0.3000, 0.0000, 1.8500, 0.0000, 0.0000, 0.0000)
Expand All @@ -55,7 +55,7 @@
N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
N..... SELECT_TOOL(0)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(0)
N..... CHANGE_TOOL()
N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... SET_XY_ROTATION(0.0000)
N..... SELECT_PLANE(CANON_PLANE_XY)
Expand Down
2 changes: 1 addition & 1 deletion tests/ccomp/mill-g90g91g92/expected
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
N..... USE_LENGTH_UNITS(CANON_UNITS_INCHES)
N..... SELECT_TOOL(3)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(3)
N..... CHANGE_TOOL()
N..... STRAIGHT_TRAVERSE(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... SET_FEED_RATE(100.0000)
N..... STRAIGHT_TRAVERSE(0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000)
Expand Down
2 changes: 1 addition & 1 deletion tests/ccomp/mill-line-arc-entry/expected
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
N..... COMMENT("with compensation")
N..... SELECT_TOOL(4)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(4)
N..... CHANGE_TOOL()
N..... STRAIGHT_TRAVERSE(1.0000, 5.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... COMMENT("interpreter: cutter radius compensation on left")
N..... STRAIGHT_FEED(1.5000, 4.0000, 0.0000, 0.0000, 0.0000, 0.0000)
Expand Down
2 changes: 1 addition & 1 deletion tests/interp/cam-nisley/expected
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
N..... COMMENT("set up the tool")
N..... SELECT_TOOL(1)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(1)
N..... CHANGE_TOOL()
N..... COMMENT("-----------------")
N..... MESSAGE("Verify METRIC Sherline.tbl file!")
N..... MESSAGE("Align XY=0 at center, Z=0 at surface, spindle to match S value, hit [Run]")
Expand Down
2 changes: 1 addition & 1 deletion tests/interp/compile/use-rs274.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void USE_NO_SPINDLE_FORCE() {}
void SET_TOOL_TABLE_ENTRY(int pocket, int toolno, EmcPose offset, double diameter,
double frontangle, double backangle, int orientation) {}
void USE_TOOL_LENGTH_OFFSET(EmcPose offset) {}
void CHANGE_TOOL(int slot) {}
void CHANGE_TOOL() {}
void SELECT_TOOL(int tool) {}
void CHANGE_TOOL_NUMBER(int number) {}
void RELOAD_TOOLDATA() {}
Expand Down
8 changes: 4 additions & 4 deletions tests/interp/g10/g10-l1-l10/expected
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
N..... SET_TOOL_TABLE_ENTRY(0, 1, 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
N..... SELECT_TOOL(1)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(1)
N..... CHANGE_TOOL()
N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
N..... MESSAGE(" should be 0 0 0: 0.000000 0.000000 0.000000")
N..... SET_TOOL_TABLE_ENTRY(1, 1, 1.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
Expand Down Expand Up @@ -48,7 +48,7 @@
N..... SET_TOOL_TABLE_ENTRY(0, 1, 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
N..... SELECT_TOOL(1)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(1)
N..... CHANGE_TOOL()
N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
N..... STRAIGHT_TRAVERSE(0.1000, 0.2000, 0.3000, 0.0000, 0.0000, 0.0000)
N..... MESSAGE(" should be 0 0 0: 0.000000 0.000000 0.000000")
Expand Down Expand Up @@ -85,7 +85,7 @@
N..... SET_TOOL_TABLE_ENTRY(0, 1, 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
N..... SELECT_TOOL(1)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(1)
N..... CHANGE_TOOL()
N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
N..... MESSAGE(" should be 0 0 0: 0.000000 0.000000 0.000000")
N..... SET_TOOL_TABLE_ENTRY(1, 1, -0.7071 -0.7071 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
Expand All @@ -108,7 +108,7 @@
N..... SET_TOOL_TABLE_ENTRY(0, 1, 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
N..... SELECT_TOOL(1)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(1)
N..... CHANGE_TOOL()
N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
N..... MESSAGE(" should be 0 0 0: 0.000000 0.000000 0.000000")
N..... SET_TOOL_TABLE_ENTRY(1, 1, -0.7071 -0.7071 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
Expand Down
4 changes: 2 additions & 2 deletions tests/interp/g10/g10-l11/expected
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
N..... SET_TOOL_TABLE_ENTRY(0, 1, 0.0000 0.0000 -3.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
N..... SELECT_TOOL(1)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(1)
N..... CHANGE_TOOL()
N..... MESSAGE("-3.000000")
N..... SET_G5X_OFFSET(2, 4.0000, 5.0000, -6.0000, 0.0000, 0.0000, 0.0000)
N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
Expand All @@ -42,7 +42,7 @@
N..... SET_TOOL_TABLE_ENTRY(0, 1, 0.0000 0.0000 -3.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
N..... SELECT_TOOL(1)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(1)
N..... CHANGE_TOOL()
N..... MESSAGE("-3.000000")
N..... SET_G5X_OFFSET(2, 4.0000, 5.0000, -6.0000, 0.0000, 0.0000, 0.0000)
N..... SET_G92_OFFSET(-43.0622, -47.4282, -76.0000, 0.0000, 0.0000, 0.0000)
Expand Down
2 changes: 1 addition & 1 deletion tests/interp/g76/expected
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
N..... COMMENT("thread")
N..... SELECT_TOOL(4)
N..... STOP_SPINDLE_TURNING(0)
N..... CHANGE_TOOL(4)
N..... CHANGE_TOOL()
N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.7000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
N..... SET_SPINDLE_SPEED(0, 800.0000)
N..... START_SPINDLE_CLOCKWISE(0)
Expand Down
2 changes: 1 addition & 1 deletion tests/remap/introspect/expected
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ executing
7 N..... MESSAGE(" before introspect: call_level= 0.000000")
8 N..... SELECT_TOOL(3)
9 N..... STOP_SPINDLE_TURNING(0)
10 N..... CHANGE_TOOL(3)
10 N..... CHANGE_TOOL()
11 N..... SET_FEED_RATE(200.0000)
12 N..... SET_SPINDLE_SPEED(0, 3000.0000)
13 N..... START_SPINDLE_CLOCKWISE(0)
Expand Down
2 changes: 1 addition & 1 deletion tests/remap/oword-pycall/expected
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ multiply: number of arguments= 3
7 N..... USE_LENGTH_UNITS(CANON_UNITS_INCHES)
8 N..... SELECT_TOOL(1)
9 N..... STOP_SPINDLE_TURNING(0)
10 N..... CHANGE_TOOL(1)
10 N..... CHANGE_TOOL()
11 N..... USE_TOOL_LENGTH_OFFSET(10.0000 0.0000 20.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
12 N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
13 N..... SET_TOOL_TABLE_ENTRY(1, 1, 20.0000 30.0000 40.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000, 0.0000, 0.0000, 0)
Expand Down

0 comments on commit c5412d5

Please sign in to comment.