Beispiel #1
0
 def executeRun(self):
     sequence = MKUtils.taskModeMDI(self.mk)
     sequence.append(MKCommandTaskExecute('M6 T0'))
     sequence.append(
         MKCommandWaitUntil(lambda: self.mk['status.io.tool.nr'] <= 0))
     sequence.extend(MKUtils.taskModeAuto(self.mk, True))
     sequence.append(MKCommandTaskRun(False))
     self.mk['command'].sendCommands(sequence)
Beispiel #2
0
    def executeUpload(self):
        '''Post process the current Path.Job and upload the resulting g-code into MK.
        Tag the uploaded g-code with the job and a hash so we can determine if the uploaded
        version is consistent with what is currently in FC.'''

        job = self.job
        if job:
            currTool = None
            postlist = []
            for obj in job.Operations.Group:
                tc = PathUtil.toolControllerForOp(obj)
                if tc is not None:
                    if tc.ToolNumber != currTool:
                        postlist.append(tc)
                        currTool = tc.ToolNumber
                postlist.append(obj)

            post = PathPost.CommandPathPost()
            fail, gcode = post.exportObjectsWith(postlist, job, False)
            if not fail:
                print("POST: ", fail)
                preamble = "(FreeCAD.Job: %s)\n(FreeCAD.File: %s)\n(FreeCAD.Signature: %d)\n" % (
                    job.Name, job.Document.FileName,
                    MKUtils.pathSignature(job.Path))
                buf = io.BytesIO((preamble + gcode).encode())
                endpoint = self.mk.instance.endpoint.get('file')
                if endpoint:
                    ftp = ftplib.FTP()
                    ftp.connect(endpoint.address(), endpoint.port())
                    ftp.login()
                    ftp.storbinary("STOR %s" % self.mk.RemoteFilename, buf)
                    ftp.quit()
                    sequence = MKUtils.taskModeMDI(self.mk)
                    for tc in job.ToolController:
                        t = tc.Tool
                        radius = float(t.Diameter) / 2 if hasattr(
                            t, 'Diameter') else 0.
                        offset = t.LengthOffset if hasattr(
                            t, 'LengthOffset') else 0.
                        sequence.append(
                            MKCommandTaskExecute(
                                "G10 L1 P%d R%g Z%g" %
                                (tc.ToolNumber, radius, offset)))
                    sequence.extend(MKUtils.taskModeAuto(self.mk))
                    sequence.append(MKCommandTaskReset(False))
                    sequence.extend([
                        MKCommandOpenFile(self.mk.remoteFilePath(), True),
                        MKCommandOpenFile(self.mk.remoteFilePath(), False)
                    ])
                    sequence.append(MKCommandTaskRun(True))
                    self.mk['command'].sendCommands(sequence)
                else:
                    PathLog.error('No endpoint found')
            else:
                PathLog.error('Post processing failed')
Beispiel #3
0
    def executeUpload(self):
        job = self.job
        if job:
            currTool = None
            postlist = []
            for obj in job.Operations.Group:
                tc = PathUtil.toolControllerForOp(obj)
                if tc is not None:
                    if tc.ToolNumber != currTool:
                        postlist.append(tc)
                        currTool = tc.ToolNumber
                postlist.append(obj)

            post = PathPost.CommandPathPost()
            fail, gcode = post.exportObjectsWith(postlist, job, False)
            if not fail:
                print("POST: ", fail)
                preamble = "(FreeCAD.Job: %s)\n(FreeCAD.File: %s)\n(FreeCAD.Signature: %d)\n" % (
                    job.Name, job.Document.FileName,
                    MKUtils.pathSignature(job.Path))
                buf = io.BytesIO((preamble + gcode).encode())
                endpoint = self.mk.instance.endpoint.get('file')
                if endpoint:
                    ftp = ftplib.FTP()
                    ftp.connect(endpoint.address(), endpoint.port())
                    ftp.login()
                    ftp.storbinary("STOR %s" % self.mk.RemoteFilename, buf)
                    ftp.quit()
                    sequence = MKUtils.taskModeMDI(self.mk)
                    for tc in job.ToolController:
                        t = tc.Tool
                        sequence.append(
                            MKCommandTaskExecute("G10 L1 P%d R%g Z%g" %
                                                 (tc.ToolNumber, t.Diameter /
                                                  2., t.LengthOffset)))
                    sequence.extend(MKUtils.taskModeAuto(self.mk))
                    sequence.append(MKCommandTaskReset(False))
                    sequence.append(
                        MKCommandOpenFile(self.mk.remoteFilePath(), False))
                    self.mk['command'].sendCommands(sequence)
                else:
                    PathLog.error('No endpoint found')
            else:
                PathLog.error('Post processing failed')
Beispiel #4
0
 def executeStep(self):
     '''Perform a single step of the uploaded g-code.'''
     sequence = MKUtils.taskModeAuto(self.mk)
     sequence.append(MKCommandTaskStep())
     self.mk['command'].sendCommands(sequence)
Beispiel #5
0
 def executeStep(self):
     sequence = MKUtils.taskModeAuto(self.mk)
     sequence.append(MKCommandTaskStep())
     self.mk['command'].sendCommands(sequence)