All pastes #393658 Raw Edit

Anonymous

public text v1 · immutable
#393658 ·published 2007-03-13 19:11 UTC
rendered paste body
// Here's what we would change "tool_change" to look like:
int tool_change(int tool_num) {
    int result = call_hook("tool_change_pre", tool_num);
    if(result == RESULT_HANDLED) return;
    if(result == RESULT_ERROR) handle error;

    old standard tool change code; // error handling not shown

    result = call_hook("tool_change_post", tool_num);
    if(result == RESULT_ERROR) handle error;
}

// 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