def getGCode(self, instruction_callback, to_start_callback,
                 return_callback):
        file_text = addDebugFrame(inspect.currentframe())
        basic_params, cut_per_pass, cut_depth = self.getParams()
        stock_height = basic_params['stock_height']
        target_depth = stock_height - cut_depth
        multipass = cut_depth > cut_per_pass
        sequence = 'first'
        # pre-amble
        # Z-axis move to starting point from Z-safe
        file_text += self.machine.moveToSafeZ()
        file_text += to_start_callback()
        file_text += addDebugFrame(inspect.currentframe())
        file_text += self.machine.setMode('ABS')
        file_text += G.G0_Z(stock_height)

        if multipass:
            while stock_height > target_depth:
                stock_height -= cut_per_pass
                if stock_height <= target_depth:
                    stock_height = target_depth
                    sequence = 'last'
                # Z-axis move
                file_text += self.machine.setMode('ABS')
                file_text += G.G1_Z(stock_height)
                file_text += G.set_dwell(0.5)
                file_text += G.comment('# ' + sequence)
                file_text += instruction_callback(sequence)
                file_text += addDebugFrame(inspect.currentframe())
                sequence = 'next'
        else:
            sequence = 'only'
            file_text += G.G1_Z(target_depth)
            file_text += G.set_dwell(0.5)
            file_text += instruction_callback(sequence)
            file_text += addDebugFrame(inspect.currentframe())

        # post-amble
        file_text += self.machine.moveToSafeZ()
        file_text += return_callback()
        file_text += addDebugFrame(inspect.currentframe())
        file_text += self.machine.setMode('ABS')

        return file_text
Example #2
0
 def getGCode(self):
     file_text = addDebugFrame(inspect.currentframe())
     params = self.getParams()
     file_text += self.machine.moveToSafeZ()
     file_text += self.moveToReference()
     file_text += addDebugFrame(inspect.currentframe())
     file_text += self.machine.setMode('ABS')
     file_text += G.G0_Z(params['stock_height'])
     file_text += self.machine.setMode('INCR')
     file_text += G.G1_Z(-params['cut_depth'])
     file_text += G.set_dwell(0.5)
     file_text += self.machine.moveToSafeZ()
     file_text += self.returnFromReference()
     return file_text