def prepare_epilog(self, **words): try: if not self.value_returned: r = self.blocks[self.remap_level].executing_remap self.set_errormsg( "the %s remap procedure %s did not return a value" % (r.name, r.remap_ngc if r.remap_ngc else r.remap_py)) return INTERP_ERROR if self.blocks[self.remap_level].builtin_used: #print "---------- T builtin recursion, nothing to do" return INTERP_OK else: if self.return_value > 0: self.selected_tool = int(self.params["tool"]) self.selected_pocket = int(self.params["pocket"]) emccanon.SELECT_TOOL(self.selected_tool) return INTERP_OK else: self.set_errormsg( "T%d: aborted (return code %.1f)" % (int(self.params["tool"]), self.return_value)) return INTERP_ERROR except Exception as e: self.set_errormsg("T%d/prepare_epilog: %s" % (tool, e)) return INTERP_ERROR
def prepare_epilog(self, userdata, **words): #print "prepare_epilog cl=",self.call_level, self._pocket retval = self.return_value if retval >= 0: self.selected_pocket = self._pocket self.selected_tool = self._tool emccanon.SELECT_TOOL(self._tool) return INTERP_OK else: self.set_errormsg("T%d: aborted (return code %.4f)" % (self._tool,retval)) return INTERP_ERROR
def index_lathe_tool_with_wear(self, **words): # only run this if we are really moving the machine # skip this if running task for the screen if not self.task: yield INTERP_OK try: # check there is a tool number from the Gcode cblock = self.blocks[self.remap_level] if not cblock.t_flag: self.set_errormsg("T requires a tool number") yield INTERP_ERROR tool_raw = int(cblock.t_number) # interpet the raw tool number into tool and wear number # If it's less then 100 someone forgot to add the wear #, so we added it automatically # separate out tool number (tool) and wear number (wear), add 10000 to wear number if tool_raw < 100: tool_raw = tool_raw * 100 tool = int(tool_raw / 100) wear = 10000 + tool_raw % 100 # uncomment for debugging #print'***tool#',cblock.t_number,'toolraw:',tool_raw,'tool split:',tool,'wear split',wear if tool: # check for tool number entry in tool file (status, pocket) = self.find_tool_pocket(tool) if status != INTERP_OK: self.set_errormsg("T%d: tool entry not found" % (tool)) yield status else: tool = -1 pocket = -1 wear = -1 self.params["tool"] = tool self.params["pocket"] = pocket self.params["wear"] = wear try: self.hal_tool_comp['tool'] = tool_raw self.hal_tool_comp['wear'] = wear except: pass # index tool immediately to tool number self.selected_tool = int(self.params["tool"]) self.selected_pocket = int(self.params["pocket"]) emccanon.SELECT_TOOL(self.selected_tool) if self.selected_pocket < 0: self.set_errormsg("T0 not valid") yield INTERP_ERROR if self.cutter_comp_side: self.set_errormsg( "Cannot change tools with cutter radius compensation on") yield INTERP_ERROR self.params["tool_in_spindle"] = self.current_tool self.params["selected_tool"] = self.selected_tool self.params["current_pocket"] = self.current_pocket self.params["selected_pocket"] = self.selected_pocket # change tool try: self.selected_pocket = int(self.params["selected_pocket"]) emccanon.CHANGE_TOOL(self.selected_pocket) self.current_pocket = self.selected_pocket self.selected_pocket = -1 self.selected_tool = -1 # cause a sync() self.set_tool_parameters() self.toolchange_flag = True except: self.set_errormsg("T change aborted (return code %.1f)" % (self.return_value)) yield INTERP_ERROR # add tool offset self.execute("g43 h%d" % tool) # if the wear offset is specified, add it's offset try: if wear > 10000: self.execute("g43.2 h%d" % wear) yield INTERP_OK except: self.set_errormsg( "Tool change aborted - No wear %d entry found in tool table" % wear) yield INTERP_ERROR except: self.set_errormsg("Tool change aborted (return code %.1f)" % (self.return_value)) yield INTERP_ERROR