当前位置: 首页>>代码示例>>Python>>正文


Python Machine.read_axis_status方法代码示例

本文整理汇总了Python中machine.Machine.read_axis_status方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.read_axis_status方法的具体用法?Python Machine.read_axis_status怎么用?Python Machine.read_axis_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在machine.Machine的用法示例。


在下文中一共展示了Machine.read_axis_status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Printer

# 需要导入模块: from machine import Machine [as 别名]
# 或者: from machine.Machine import read_axis_status [as 别名]

#.........这里部分代码省略.........
            axis = {'name': axis_name}
            self.axis[axis_name] = axis
            self._configure_axis(axis, config[config_name])
        self._postconfig()

    def connect(self):
        _logger.debug("Connecting printer")
        self.machine.connect()


    def start_print(self):
        self._print_queue = PrintQueue(axis_config=self.axis, min_length=self.print_queue_min_length,
                                       max_length=self.print_queue_max_length, default_target_speed=self.default_speed)
        self.machine.start_motion()
        self.printing = True
        self.led_manager.light(1, True)


    def finish_print(self):
        self._print_queue.finish()
        self.machine.finish_motion()
        self.printing = False
        self.led_manager.light(1, False)

    def read_motor_positons(self):
        positions = {}
        for axis_name in self.axis:
            axis_config = self.axis[axis_name]
            motor = axis_config['motor']
            position = self.machine.read_positon(motor)
            positions[axis_name] = position / axis_config['steps_per_mm']
        return positions

    def read_axis_status(self):
        status = {}
        for axis_name in self.axis:
            axis_config = self.axis[axis_name]
            motor = axis_config['motor']
            if motor:
                internal_status = self.machine.read_axis_status(motor)
                position = internal_status['position']
                position = position / axis_config['steps_per_mm']
                encoder_pos = internal_status['encoder_pos']
                encoder_pos = encoder_pos / axis_config['steps_per_mm']
                left_endstop_ = internal_status['left_endstop']
                right_endstop_ = internal_status['right_endstop']
            else:
                # todo implement
                position = 0
                encoder_pos = 0
                left_endstop_ = False
                right_endstop_ = False
            status[axis_name] = {
                "position": position,
                "encoder_pos": encoder_pos,
                "left_endstop": left_endstop_,
                "right_endstop": right_endstop_
            }
        return status


    def home(self, axis):
        for home_axis in axis:
            if not self.axis[home_axis]['end-stops'] or not self.axis[home_axis]['end-stops']['left']:
                _logger.debug("Axis %s does not have endstops - or an left end stop, cannot home it.", home_axis)
            else:
开发者ID:MbedTinkerer,项目名称:T-Bone,代码行数:70,代码来源:printer.py


注:本文中的machine.Machine.read_axis_status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。