mirror of https://github.com/Desuuuu/klipper.git
gcode: Move definition of CommandError and Coord from homing.py to gcode.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
c8434ec54b
commit
ea85d419de
|
@ -1,6 +1,6 @@
|
||||||
# G-Code G1 movement commands (and associated coordinate manipulation)
|
# G-Code G1 movement commands (and associated coordinate manipulation)
|
||||||
#
|
#
|
||||||
# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
|
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
import logging
|
import logging
|
||||||
|
@ -34,6 +34,7 @@ class GCodeMove:
|
||||||
gcode.register_command('G0', self.cmd_G1)
|
gcode.register_command('G0', self.cmd_G1)
|
||||||
gcode.register_command('M114', self.cmd_M114, True)
|
gcode.register_command('M114', self.cmd_M114, True)
|
||||||
gcode.register_command('GET_POSITION', self.cmd_GET_POSITION, True)
|
gcode.register_command('GET_POSITION', self.cmd_GET_POSITION, True)
|
||||||
|
self.Coord = gcode.Coord
|
||||||
# G-Code coordinate manipulation
|
# G-Code coordinate manipulation
|
||||||
self.absolute_coord = self.absolute_extrude = True
|
self.absolute_coord = self.absolute_extrude = True
|
||||||
self.base_position = [0.0, 0.0, 0.0, 0.0]
|
self.base_position = [0.0, 0.0, 0.0, 0.0]
|
||||||
|
@ -94,9 +95,9 @@ class GCodeMove:
|
||||||
'extrude_factor': self.extrude_factor,
|
'extrude_factor': self.extrude_factor,
|
||||||
'absolute_coordinates': self.absolute_coord,
|
'absolute_coordinates': self.absolute_coord,
|
||||||
'absolute_extrude': self.absolute_extrude,
|
'absolute_extrude': self.absolute_extrude,
|
||||||
'homing_origin': homing.Coord(*self.homing_position),
|
'homing_origin': self.Coord(*self.homing_position),
|
||||||
'position': homing.Coord(*self.last_position),
|
'position': self.Coord(*self.last_position),
|
||||||
'gcode_position': homing.Coord(*move_position),
|
'gcode_position': self.Coord(*move_position),
|
||||||
}
|
}
|
||||||
def reset_last_position(self):
|
def reset_last_position(self):
|
||||||
if self.is_printer_ready:
|
if self.is_printer_ready:
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
# Parse gcode commands
|
# Parse gcode commands
|
||||||
#
|
#
|
||||||
# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
|
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
import os, re, logging, collections, shlex
|
import os, re, logging, collections, shlex
|
||||||
import homing
|
|
||||||
|
class CommandError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
Coord = collections.namedtuple('Coord', ('x', 'y', 'z', 'e'))
|
||||||
|
|
||||||
class GCodeCommand:
|
class GCodeCommand:
|
||||||
error = homing.CommandError
|
error = CommandError
|
||||||
def __init__(self, gcode, command, commandline, params, need_ack):
|
def __init__(self, gcode, command, commandline, params, need_ack):
|
||||||
self._command = command
|
self._command = command
|
||||||
self._commandline = commandline
|
self._commandline = commandline
|
||||||
|
@ -68,7 +72,8 @@ class GCodeCommand:
|
||||||
|
|
||||||
# Parse and dispatch G-Code commands
|
# Parse and dispatch G-Code commands
|
||||||
class GCodeDispatch:
|
class GCodeDispatch:
|
||||||
error = homing.CommandError
|
error = CommandError
|
||||||
|
Coord = Coord
|
||||||
def __init__(self, printer):
|
def __init__(self, printer):
|
||||||
self.printer = printer
|
self.printer = printer
|
||||||
self.is_fileinput = not not printer.get_start_args().get("debuginput")
|
self.is_fileinput = not not printer.get_start_args().get("debuginput")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Code for state tracking during homing operations
|
# Code for state tracking during homing operations
|
||||||
#
|
#
|
||||||
# Copyright (C) 2016-2019 Kevin O'Connor <kevin@koconnor.net>
|
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
import logging, math, collections
|
import logging, math, collections
|
||||||
|
@ -157,8 +157,3 @@ def multi_complete(printer, completions):
|
||||||
return completions[0]
|
return completions[0]
|
||||||
cb = (lambda e: all([c.wait() for c in completions]))
|
cb = (lambda e: all([c.wait() for c in completions]))
|
||||||
return printer.get_reactor().register_callback(cb)
|
return printer.get_reactor().register_callback(cb)
|
||||||
|
|
||||||
class CommandError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
Coord = collections.namedtuple('Coord', ('x', 'y', 'z', 'e'))
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
import sys, os, gc, optparse, logging, time, collections, importlib
|
import sys, os, gc, optparse, logging, time, collections, importlib
|
||||||
import util, reactor, queuelogger, msgproto, homing
|
import util, reactor, queuelogger, msgproto
|
||||||
import gcode, configfile, pins, mcu, toolhead, webhooks
|
import gcode, configfile, pins, mcu, toolhead, webhooks
|
||||||
|
|
||||||
message_ready = "Printer is ready"
|
message_ready = "Printer is ready"
|
||||||
|
@ -47,7 +47,7 @@ Printer is shutdown
|
||||||
|
|
||||||
class Printer:
|
class Printer:
|
||||||
config_error = configfile.error
|
config_error = configfile.error
|
||||||
command_error = homing.CommandError
|
command_error = gcode.CommandError
|
||||||
def __init__(self, main_reactor, bglogger, start_args):
|
def __init__(self, main_reactor, bglogger, start_args):
|
||||||
self.bglogger = bglogger
|
self.bglogger = bglogger
|
||||||
self.start_args = start_args
|
self.start_args = start_args
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
# Code for coordinating events on the printer toolhead
|
# Code for coordinating events on the printer toolhead
|
||||||
#
|
#
|
||||||
# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
|
# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
import math, logging, importlib
|
import math, logging, importlib
|
||||||
import mcu, homing, chelper, kinematics.extruder
|
import mcu, chelper, kinematics.extruder
|
||||||
|
|
||||||
# Common suffixes: _d is distance (in mm), _v is velocity (in
|
# Common suffixes: _d is distance (in mm), _v is velocity (in
|
||||||
# mm/second), _v2 is velocity squared (mm^2/s^2), _t is time (in
|
# mm/second), _v2 is velocity squared (mm^2/s^2), _t is time (in
|
||||||
|
@ -196,7 +196,6 @@ class DripModeEndSignal(Exception):
|
||||||
|
|
||||||
# Main code to track events (and their timing) on the printer toolhead
|
# Main code to track events (and their timing) on the printer toolhead
|
||||||
class ToolHead:
|
class ToolHead:
|
||||||
Coord = homing.Coord
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.reactor = self.printer.get_reactor()
|
self.reactor = self.printer.get_reactor()
|
||||||
|
@ -251,6 +250,8 @@ class ToolHead:
|
||||||
self.trapq_free_moves = ffi_lib.trapq_free_moves
|
self.trapq_free_moves = ffi_lib.trapq_free_moves
|
||||||
self.step_generators = []
|
self.step_generators = []
|
||||||
# Create kinematics class
|
# Create kinematics class
|
||||||
|
gcode = self.printer.lookup_object('gcode')
|
||||||
|
self.Coord = gcode.Coord
|
||||||
self.extruder = kinematics.extruder.DummyExtruder(self.printer)
|
self.extruder = kinematics.extruder.DummyExtruder(self.printer)
|
||||||
kin_name = config.get('kinematics')
|
kin_name = config.get('kinematics')
|
||||||
try:
|
try:
|
||||||
|
@ -265,7 +266,6 @@ class ToolHead:
|
||||||
logging.exception(msg)
|
logging.exception(msg)
|
||||||
raise config.error(msg)
|
raise config.error(msg)
|
||||||
# Register commands
|
# Register commands
|
||||||
gcode = self.printer.lookup_object('gcode')
|
|
||||||
gcode.register_command('G4', self.cmd_G4)
|
gcode.register_command('G4', self.cmd_G4)
|
||||||
gcode.register_command('M400', self.cmd_M400)
|
gcode.register_command('M400', self.cmd_M400)
|
||||||
gcode.register_command('SET_VELOCITY_LIMIT',
|
gcode.register_command('SET_VELOCITY_LIMIT',
|
||||||
|
|
|
@ -3,13 +3,8 @@
|
||||||
# Copyright (C) 2020 Eric Callahan <arksine.code@gmail.com>
|
# Copyright (C) 2020 Eric Callahan <arksine.code@gmail.com>
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license
|
# This file may be distributed under the terms of the GNU GPLv3 license
|
||||||
import logging
|
import logging, socket, os, sys, errno, json
|
||||||
import socket
|
import gcode
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import errno
|
|
||||||
import json
|
|
||||||
import homing
|
|
||||||
|
|
||||||
# Json decodes strings as unicode types in Python 2.x. This doesn't
|
# Json decodes strings as unicode types in Python 2.x. This doesn't
|
||||||
# play well with some parts of Klipper (particuarly displays), so we
|
# play well with some parts of Klipper (particuarly displays), so we
|
||||||
|
@ -27,7 +22,7 @@ def byteify(data, ignore_dicts=False):
|
||||||
for k, v in data.items()}
|
for k, v in data.items()}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
class WebRequestError(homing.CommandError):
|
class WebRequestError(gcode.CommandError):
|
||||||
def __init__(self, message,):
|
def __init__(self, message,):
|
||||||
Exception.__init__(self, message)
|
Exception.__init__(self, message)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue