def _getGCode(self, order_int):
        file_text = self._startProgram()
        # move to start, at safe-Z, in INCR mode
        file_text += G.set_INCR_mode()
        file_text += G.G0_XY(( \
            self.startRefs['x_starting_ref'], \
            self.startRefs['y_starting_ref'] \
        ))

        height_to_cut = self.workpiece_params['stock_height']

        while height_to_cut > 0:
            # move down to top of stock
            file_text += G.set_ABS_mode()
            file_text += G.G0_Z(height_to_cut)
            # get to cutting height
            height_to_cut = max(
                height_to_cut - self.cutting_params['cut_per_pass'], 0)
            file_text += G.set_ABS_mode()
            file_text += G.G1_Z(
                height_to_cut)  # could be G0 here, but it's good practice

            # This is other magic for A/B: special order of paths.
            file_text += self.cutFingers(order_int)
            file_text += self.returnToStart(order_int)

        file_text += self.returnToHome()
        file_text += self._endProgram()
        return file_text
    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
예제 #3
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