gcode_reader.emulate.machines.masterprint ========================================= .. py:module:: gcode_reader.emulate.machines.masterprint Classes ------- .. autoapisummary:: gcode_reader.emulate.machines.masterprint.MasterPrint gcode_reader.emulate.machines.masterprint.MasterPrintExtruder gcode_reader.emulate.machines.masterprint.MasterPrintMotionProfile gcode_reader.emulate.machines.masterprint.MasterPrintScrewModel Module Contents --------------- .. py:class:: MasterPrint(**options) Bases: :py:obj:`gcode_reader.emulate.machine.Machine` Represents the Ingersoll MasterPrint Manufacturing system. This class coordinates the machine's motion, tools, and G-code parsing specifics. It handles Ingersoll-specific G-codes for units, positioning, and virtual axes (like 'CA' for Cross-Sectional Area). Initializes a new Machine instance. :param tools: A tuple of Tool instances for the machine to use. Defaults to None. :type tools: Tuple[Tool, ...], optional :param parser: An instance of a GcodeParser. Defaults to a new GcodeParser(). :type parser: GcodeParser, optional :param exporter: An instance of a GcodeExporter. Defaults to a new GcodeExporter(). :type exporter: GcodeExporter, optional :param \*\*options: Keyword arguments passed to the constructor of the machine's `MachineOptions` type. .. py:method:: gcode_file_to_operation(filepath: str, operation_type=AdditiveOperation) Parse a G-code file and emulate into an Operation object. :param filepath: Path to the G-code file. :type filepath: str :param operation_type: The class to instantiate for the operation. Defaults to AdditiveOperation. :type operation_type: type, optional :returns: The emulated operation. :rtype: Operation .. py:method:: operation_to_dataframe(operation: gcode_reader.emulate.operations.Operation) Converts an Operation to a DataFrame with MasterPrint-aware tagging. Extends the base implementation with a second pass that corrects tags for Move commands where the screw extruder was actively depositing material. These rows are tagged LINEAR_MOVE by default (since the G-code issues separate EXTRUDERB commands rather than inline extrusion parameters), but should be MOVE_EXTRUDE when deposited_volume > 0. :param operation: The operation to convert. :type operation: Operation :returns: DataFrame with corrected MOVE_EXTRUDE tags. :rtype: pd.DataFrame .. py:method:: process_operation(operation: gcode_reader.emulate.operations.Operation, force=False) -> gcode_reader.emulate.operations.Operation Fully processes an operation, including a second pass for extruder data. This method extends the base `Machine`'s processing pipeline to accommodate the `ScrewExtruder`'s dependency on accurate time estimates for its calculations. The process is as follows: 1. It first calls `super().process_operation()`, which runs the full kinematic simulation and applies the motion profile. This is the critical step that calculates and populates the `elapsed_time` for each movement command. 2. It then performs a second pass, iterating through each command and its now time-aware `process_data`. This allows the extruder tool to use the `elapsed_time` to accurately calculate `deposited_volume`. :param operation: The additive manufacturing operation to process. :type operation: AdditiveOperation :param force: If True, re-processes the operation even if it has been processed before. Defaults to False. :type force: bool, optional :returns: The operation with fully populated process data, including time-dependent extruder calculations. :rtype: AdditiveOperation .. py:attribute:: motion_profile .. py:attribute:: options .. py:attribute:: process_command_helpers .. py:property:: volumetric_mode Get the machine-wide volumetric mode state. .. py:class:: MasterPrintExtruder(options=None, model=MasterPrintScrewModel(), pellet_density=1100, volumetric_mode=False) Bases: :py:obj:`gcode_reader.emulate.extruders.ScrewExtruder` Represents the screw extruder hardware on the MasterPrint. Manages state related to volumetric modes, material density, and processing logic that routes commands to the underlying `MasterPrintScrewModel`. .. attribute:: volumetric_mode If True, extruder operates based on bead geometry. :type: bool .. attribute:: pellet_density Material density in kg/m^3. :type: float .. attribute:: on Current state of the extruder motor. :type: bool Initialize the MasterPrint extruder. :param options: Configuration options. Defaults to None. :type options: dict, optional :param model: The physical model of the screw. Defaults to MasterPrintScrewModel(). :type model: MasterPrintScrewModel, optional :param pellet_density: Material density. Defaults to 1100. :type pellet_density: float, optional :param volumetric_mode: Initial state of volumetric mode. Defaults to False. :type volumetric_mode: bool, optional :raises TypeError: If the provided model is not a MasterPrintScrewModel. .. py:method:: process_command(command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData) Process a G-code command and calculate extrusion parameters. Updates the extruder state based on the command type and calculates the resulting RPM and deposited volume. In volumetric mode, bead area from move commands is cached for subsequent calculations. :param command: The G-code command to process. :param process_data: Current process state containing bead geometry, feed rate, and other parameters. :returns: Updated process data with calculated extrusion rate and volume. :rtype: AdditiveProcessData .. py:attribute:: on :value: False .. py:attribute:: pellet_density .. py:attribute:: volumetric_mode :value: False .. py:class:: MasterPrintMotionProfile(max_jerk=None, max_accleration=None, max_velocity=None, traverse_feed_rate=10000, angle_factor=0.5) Bases: :py:obj:`gcode_reader.emulate.motion.MotionProfile` Defines the kinematic limits and default behaviors for the MasterPrint machine. .. attribute:: traverse_feed_rate The default feed rate for rapid moves (G0). :type: float Initialize the motion profile. :param max_jerk: Maximum jerk allowed. Defaults to None. :type max_jerk: float, optional :param max_accleration: Maximum acceleration allowed. Defaults to None. :type max_accleration: float, optional :param max_velocity: Maximum velocity allowed. Defaults to None. :type max_velocity: float, optional :param traverse_feed_rate: Feed rate for G0 moves in mm/min. Defaults to 10000. :type traverse_feed_rate: float, optional :param angle_factor: Factor for cornering velocity calculations. Defaults to 0.5. :type angle_factor: float, optional .. py:attribute:: traverse_feed_rate :value: 10000 .. py:class:: MasterPrintScrewModel(nozzle_diameter=0, displacement=1) Bases: :py:obj:`gcode_reader.emulate.extruders.ScrewModel` Models the physics and calibration curves of the MasterPrint screw extruder. This class handles the conversion between requested Throughput (kg/hr) and Screw RPM using a cubic polynomial calibration curve. .. attribute:: rpm_coefficients Coefficients [a, b, c, d] for calculating RPM from Throughput (x) via `a*x^3 + b*x^2 + c*x + d`. :type: tuple .. attribute:: throughput_coefficients Coefficients [a, b, c, d] for calculating Throughput from RPM (x) via `a*x^3 + b*x^2 + c*x + d`. :type: tuple Initialize the screw model. :param nozzle_diameter: Diameter of the nozzle in mm. Defaults to 0. :type nozzle_diameter: float, optional :param displacement: Theoretical displacement per revolution. Defaults to 1. :type displacement: float, optional .. py:method:: calc_deposited_volume(extruder: gcode_reader.emulate.extruders.ScrewExtruder, command: gcode_reader.emulate.commands.Extrude, process_data: gcode_reader.emulate.operations.AdditiveProcessData, pellet_density=1100) Calculate the deposited volume given a known RPM. Used when the machine is commanding specific RPMs directly rather than requesting a specific volume or bead shape. :param extruder: The extruder instance. :type extruder: ScrewExtruder :param command: The G-code command (containing explicit RPM if present). :type command: Extrude :param process_data: State data including elapsed time. :type process_data: AdditiveProcessData :param pellet_density: Density of material in kg/m^3. Defaults to 1100. :type pellet_density: float, optional :returns: A tuple of (deposited_volume, RPM). :rtype: (float, float) .. py:method:: calc_extrusion_rate(extruder: gcode_reader.emulate.extruders.ScrewExtruder, command: gcode_reader.emulate.commands.Extrude, process_data: gcode_reader.emulate.operations.AdditiveProcessData, pellet_density=1100, volumetric_mode=False) Calculate the required RPM and Volume for a given command. This method determines the flow rate required to achieve a specific bead geometry (in volumetric mode) or volume (in standard mode) and converts that flow rate to RPM using the calibration coefficients. :param extruder: The extruder instance invoking this calculation. :type extruder: ScrewExtruder :param command: The current G-code command. :type command: Extrude :param process_data: State data including feed rate and time. :type process_data: AdditiveProcessData :param pellet_density: Density of material in kg/m^3. Defaults to 1100. :type pellet_density: float, optional :param volumetric_mode: If True, calculates flow based on bead cross-sectional area. Defaults to False. :type volumetric_mode: bool, optional :returns: A tuple of (RPM, deposited_volume). :rtype: (float, float) .. py:property:: rpm_coefficients Get the coefficients for the Throughput -> RPM polynomial. .. py:property:: throughput_coefficients Get the coefficients for the RPM -> Throughput polynomial.