probe.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:hacked_cnc 作者: hackerspace 项目源码 文件源码
def handle_response(self, idx, txt):
        root = self.comtree.invisibleRootItem()
        item = root.child(idx)

        item.setText(0, time.strftime("%Y.%m.%d. %H:%M:%S", time.localtime()))
        if not txt:
            txt = 'ok'
        item.setText(2, txt)
        item.setCheckState(0, Qt.Checked)
        self.comtree.scrollToItem(item)

        cmd = item.text(1)

        proc_events()

        if 'G0' in cmd or 'G1' in cmd:
            x, y, z = parse.xyz(cmd[2:])
            # should probably emit signals

            self.current_x = x
            self.current_y = y
            self.current_z = z

        if 'G38.2' in cmd:
            try:
                # e.g. Probe not tripped from LinuxCNC
                # (we get error message from backend)
                if 'error' in txt:
                    z = -999.0
                else:
                    z = parse.probe(txt)
            except:
                self.err('Unable to parse probe: {}'.format(txt))
                self.err('Is your flavor ({}) correct?'.format(self.flavor))
                z = -999.0

            self.gl.result.data.append((self.current_x, self.current_y, z))
            self.update_result()
            self['probe result.lowest'] = min(self['probe result.lowest'], z)
            self['probe result.highest'] = max(self['probe result.highest'], z)
            self['probe result.last'] = z
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号