// Here's what we would change "tool_change" to look like:
int tool_change(int tool_num) {
if (!call_hook("tool_change_pre", tool_num)) {
old standard tool change precondition code; // error handling not shown
}
if (!call_hook("tool_change_do", tool_num)) {
old standard tool change code; // error handling not shown
}
if (!call_hook("tool_change_post", tool_num) {
old standard tool change postcondition code; // error handling not shown
}
}
// And here's a Python implementation of a next-to-the-table tool changer
def tool_change_pre(int tool_num):
release_current_tool() # not shown
traverse(UNCHANGED, UNCHANGED, 2.0)
traverse(toolchange_x, toolchange_y + tool_num * toolchange_dx, UNCHANGED)
feed(UNCHANGED, UNCHANGED, 1.0, feedrate=12)
set_digital_io(INDEX_TOOL_CLAMP, True)
traverse(UNCHANGED, UNCHANGED, 2.0)
return HANDLED