class G92(CommandWithParams): """Set position.""" param_letters = utils.str_to_chars("xyze") def __init__( self, x: float = None, y: float = None, z: float = None, e: float = None, line_number: int = None, ): if not any([elem is not None for elem in [x, y, z, e]]): raise CommandMissingParamError("At least one axis must be specified.") super().__init__(line_number=line_number) self.x = x self.y = y self.z = z self.e = e def __repr__(self): return ( f"{self.__class__.__name__}" f"(line_number={self.line_number}, " f"x={self.x}, y={self.y}, z={self.z})" )
class ArcMove(Move): """Generic Arc Move.""" param_letters = utils.str_to_chars("xyijef") def __init__( self, x: float = None, y: float = None, i: float = None, j: float = None, e: float = None, f: float = None, line_number: int = None, ): params_mandatory = {"x": x, "y": y, "i": i, "j": j, "e": e} if not all([elem is not None for elem in params_mandatory.values()]): raise CommandMissingParamError( f"The following parameters must be specified: " f"{', '.join(params_mandatory.keys())}." ) super().__init__(x=x, y=y, e=e, f=f, line_number=line_number) self.i = i self.j = j def __repr__(self): return ( f"{self.__class__.__name__}" f"(line_number={self.line_number}, " f"x={self.x}, y={self.y}, i={self.i}, " f"j={self.j}, e={self.e}, f={self.f})" )
class LineMove(Move): """Generic Line Move """ param_letters = utils.str_to_chars("xyzefhrs") __slots__ = utils.str_to_chars("zhrs") def __init__( self, x: float = None, y: float = None, z: float = None, e: float = None, f: float = None, h: float = None, r: float = None, s: float = None, line_number: int = None, ): if not any([elem is not None for elem in [x, y, z, e, f, h, r, s]]): raise CommandMissingParamError( "At least one G-code parameter must be specified." ) super().__init__(x=x, y=y, e=e, f=f, line_number=line_number) self.z = z self.h = h self.r = r self.s = s def __repr__(self): return ( f"{self.__class__.__name__}" f"(line_number={self.line_number}, " f"x={self.x}, y={self.y}, z={self.z}, e={self.e}, " f"f={self.f}, h={self.h}, r={self.r}, s={self.s})" )
class G28(CommandWithParams): """Move to origin (home).""" param_letters = utils.str_to_chars("xyz") def __init__(self, x: bool, y: bool, z: bool, line_number: int = None): super().__init__(line_number=line_number) self.x = x self.y = y self.z = z def __repr__(self): return ( f"{self.__class__.__name__}" f"(line_number={self.line_number}, " f"x={self.x}, y={self.y}, z={self.z})" )
class M109(SetTemperatureExtruder): """Set Extruder Temperature and Wait """ param_letters = utils.str_to_chars("srt") def __init__( self, s: float, r: float = None, t: int = None, line_number: int = None ): super().__init__(s=s, r=r, line_number=line_number) self.t = t def __repr__(self): return ( f"{self.__class__.__name__}" f"(line_number={self.line_number}, " f"s={self.s}, r={self.r}, t={self.t})" )
class Move(CommandWithParams, ABC): """Move command base class.""" __slots__ = utils.str_to_chars("xyef") def __init__( self, x: Optional[float] = None, y: Optional[float] = None, e: Optional[float] = None, f: Optional[float] = None, line_number: int = None, ): super().__init__(line_number) self.x: Optional[float] = x self.y: Optional[float] = y self.e: Optional[float] = e self.f: Optional[float] = f
"""G-code lexemes info.""" from layerview.gcode.utils import str_to_chars LETTERS_COMMAND = str_to_chars("gtmnd") LETTERS_PARAM = str_to_chars("xyzijefhrs")