示例#1
0
 def addRapidMoveToSafeZ(self):
     safeZ = float(self.param['safeZ'])
     self.listOfCmds.append(gcode_cmd.Space())
     commentStr = '{0}: rapid move to safe z'.format(
         self.__class__.__name__)
     self.listOfCmds.append(gcode_cmd.Comment(commentStr))
     self.listOfCmds.append(gcode_cmd.RapidMotion(z=safeZ))
示例#2
0
 def addRapidMoveToPos(self, **kwarg):
     self.listOfCmds.append(gcode_cmd.Space())
     try:
         pointName = kwarg.pop('comment')
     except KeyError:
         pointName = '{0}'.format(kwarg)
     commentStr = '{0}: rapid move to {1}'.format(self.__class__.__name__,
                                                  pointName)
     self.listOfCmds.append(gcode_cmd.Comment(commentStr))
     self.listOfCmds.append(gcode_cmd.RapidMotion(**kwarg))
示例#3
0
def getUniDirRasterRect(point0, point1, step, cutZ, retZ,
                        keys=('x', 'y', 'z')):
    """
    Generates a uni-directional rastered rectangle path.

    Details: ...
    """
    x0, y0 = point0
    x1, y1 = point1
    cmdList = []
    # Get step size and raster completion function
    if y0 < y1:
        dy = step

        def outOfBounds(y):
            return y > y1
    else:
        dy = -step

        def outOfBounds(y):
            return y < y1

    # Get function for alternating x direction
    def getAlternateX(xLast):
        if xLast == x0:
            return x1
        else:
            return x0

    # Generate raster
    x, y = x0, y0
    kx, ky, kz = keys
    isFirst = True
    isLast = False
    cmdList.append(gcode_cmd.LinearFeed(**{kx: x, ky: y, kz: cutZ}))
    while 1:
        x = getAlternateX(x)
        if x == x0:
            cmdList.append(gcode_cmd.LinearFeed(**{kz: retZ}))
            cmdList.append(gcode_cmd.RapidMotion(**{kx: x, ky: y}))
        else:
            cmdList.append(gcode_cmd.LinearFeed(**{kz: cutZ}))
            if isFirst:
                isFirst = False
            else:
                y += dy
                if outOfBounds(y):
                    y = y1
                    isLast = True
                cmdList.append(gcode_cmd.LinearFeed(**{ky: y}))
            cmdList.append(gcode_cmd.LinearFeed(**{kx: x, ky: y}))
        if isLast:
            break
    return cmdList
示例#4
0
 def getRapidToStartCmd(self, plane='xy'):
     kx, ky = tuple(plane)
     feedArgs = {kx: self.startPoint[0], ky: self.startPoint[1]}
     return gcode_cmd.RapidMotion(**feedArgs)
示例#5
0
 def getRapidCmd(self, plane='xy'):
     kx, ky = tuple(plane)
     feedArgs = {kx: self.endPoint[0], ky: self.endPoint[1]}
     return gcode_cmd.RapidMotion(feedArgs)