本文整理汇总了Python中machine.Machine.finish_motion方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.finish_motion方法的具体用法?Python Machine.finish_motion怎么用?Python Machine.finish_motion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类machine.Machine
的用法示例。
在下文中一共展示了Machine.finish_motion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Printer
# 需要导入模块: from machine import Machine [as 别名]
# 或者: from machine.Machine import finish_motion [as 别名]
class Printer(Thread):
def __init__(self, serial_port, reset_pin, print_queue_min_length=50, print_queue_max_length=100):
Thread.__init__(self)
self.ready = False
self.printing = False
self.config = None
self.homed_axis = []
self.heated_bed = None
self.extruder_heater = None
self.axis = {}
self.axis_position = {}
for axis_name in _axis_config:
self.axis_position[axis_name] = 0
self.printer_thread = None
self._print_queue = None
self.print_queue_min_length = print_queue_min_length
self.print_queue_max_length = print_queue_max_length
self._default_homing_retraction = None
self._x_step_conversion = None
self._y_step_conversion = None
self._homing_timeout = 10
self._print_queue_wait_time = 0.1
self.homed = False
self.led_manager = LedManager()
# todo why didn't this work as global constant?? - should be confugired anyway
self._FAN_OUTPUT = beagle_bone_pins.pwm_config[2]['out']
# finally create the machine
self.machine = Machine(serial_port=serial_port, reset_pin=reset_pin)
self.running = True
self.start()
def stop(self):
if self.running:
self.running = False
if self.isAlive():
self.join()
self.machine.disconnect()
def axis_names(self):
return _axis_names
def configure(self, config):
if not config:
raise PrinterError("No printer config given!")
self.config = config
printer_config = config['printer']
print_queue_config = printer_config["print-queue"]
self.print_queue_min_length = print_queue_config['min-length']
self.print_queue_max_length = print_queue_config['max-length']
self._homing_timeout = printer_config['homing-timeout']
self._default_homing_retraction = printer_config['home-retract']
self.default_speed = printer_config['default-speed']
# todo this is the fan and should be configured
PWM.start(self._FAN_OUTPUT, printer_config['fan-duty-cycle'], printer_config['fan-frequency'], 0)
if 'heated-bed' in printer_config:
bed_heater_config = printer_config['heated-bed']
self.heated_bed = self._configure_heater(bed_heater_config)
extruder_heater_config = config['extruder']['heater']
# we do not care if it the extruder heate may not be given in the config
# # - the whole point of additive printing is pretty dull w/o an heated extruder
self.extruder_heater = self._configure_heater(extruder_heater_config)
for axis_name, config_name in _axis_config.iteritems():
_logger.info("Configuring axis \'%s\' according to conf \'%s\'", axis_name, config_name)
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)
#.........这里部分代码省略.........