gcode_reader.emulate.machines.masterprint¶
Classes¶
Represents the Ingersoll MasterPrint Manufacturing system. |
|
Represents the screw extruder hardware on the MasterPrint. |
|
Defines the kinematic limits and default behaviors for the MasterPrint machine. |
|
Models the physics and calibration curves of the MasterPrint screw extruder. |
Module Contents¶
- class gcode_reader.emulate.machines.masterprint.MasterPrint(**options)[source]¶
Bases:
gcode_reader.emulate.machine.MachineRepresents 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.
- Parameters:
tools (Tuple[Tool, ...], optional) – A tuple of Tool instances for the machine to use. Defaults to None.
parser (GcodeParser, optional) – An instance of a GcodeParser. Defaults to a new GcodeParser().
exporter (GcodeExporter, optional) – An instance of a GcodeExporter. Defaults to a new GcodeExporter().
**options – Keyword arguments passed to the constructor of the machine’s MachineOptions type.
- gcode_file_to_operation(filepath: str, operation_type=AdditiveOperation)[source]¶
Parse a G-code file and emulate into an Operation object.
- operation_to_dataframe(operation: gcode_reader.emulate.operations.Operation)[source]¶
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.
- Parameters:
operation (Operation) – The operation to convert.
- Returns:
DataFrame with corrected MOVE_EXTRUDE tags.
- Return type:
pd.DataFrame
- process_operation(operation: gcode_reader.emulate.operations.Operation, force=False) gcode_reader.emulate.operations.Operation[source]¶
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.
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.
- Parameters:
operation (AdditiveOperation) – The additive manufacturing operation to process.
force (bool, optional) – If True, re-processes the operation even if it has been processed before. Defaults to False.
- Returns:
- The operation with fully populated process data,
including time-dependent extruder calculations.
- Return type:
- motion_profile¶
- options¶
- process_command_helpers¶
- property volumetric_mode¶
Get the machine-wide volumetric mode state.
- class gcode_reader.emulate.machines.masterprint.MasterPrintExtruder(options=None, model=MasterPrintScrewModel(), pellet_density=1100, volumetric_mode=False)[source]¶
Bases:
gcode_reader.emulate.extruders.ScrewExtruderRepresents 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.
Initialize the MasterPrint extruder.
- Parameters:
options (dict, optional) – Configuration options. Defaults to None.
model (MasterPrintScrewModel, optional) – The physical model of the screw. Defaults to MasterPrintScrewModel().
pellet_density (float, optional) – Material density. Defaults to 1100.
volumetric_mode (bool, optional) – Initial state of volumetric mode. Defaults to False.
- Raises:
TypeError – If the provided model is not a MasterPrintScrewModel.
- process_command(command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData)[source]¶
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.
- Parameters:
command – The G-code command to process.
process_data – Current process state containing bead geometry, feed rate, and other parameters.
- Returns:
- Updated process data with calculated
extrusion rate and volume.
- Return type:
- on = False¶
- pellet_density¶
- volumetric_mode = False¶
- class gcode_reader.emulate.machines.masterprint.MasterPrintMotionProfile(max_jerk=None, max_accleration=None, max_velocity=None, traverse_feed_rate=10000, angle_factor=0.5)[source]¶
Bases:
gcode_reader.emulate.motion.MotionProfileDefines the kinematic limits and default behaviors for the MasterPrint machine.
Initialize the motion profile.
- Parameters:
max_jerk (float, optional) – Maximum jerk allowed. Defaults to None.
max_accleration (float, optional) – Maximum acceleration allowed. Defaults to None.
max_velocity (float, optional) – Maximum velocity allowed. Defaults to None.
traverse_feed_rate (float, optional) – Feed rate for G0 moves in mm/min. Defaults to 10000.
angle_factor (float, optional) – Factor for cornering velocity calculations. Defaults to 0.5.
- traverse_feed_rate = 10000¶
- class gcode_reader.emulate.machines.masterprint.MasterPrintScrewModel(nozzle_diameter=0, displacement=1)[source]¶
Bases:
gcode_reader.emulate.extruders.ScrewModelModels 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.
- rpm_coefficients¶
Coefficients [a, b, c, d] for calculating RPM from Throughput (x) via a*x^3 + b*x^2 + c*x + d.
- Type:
- throughput_coefficients¶
Coefficients [a, b, c, d] for calculating Throughput from RPM (x) via a*x^3 + b*x^2 + c*x + d.
- Type:
Initialize the screw model.
- Parameters:
- 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)[source]¶
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.
- Parameters:
extruder (ScrewExtruder) – The extruder instance.
command (Extrude) – The G-code command (containing explicit RPM if present).
process_data (AdditiveProcessData) – State data including elapsed time.
pellet_density (float, optional) – Density of material in kg/m^3. Defaults to 1100.
- Returns:
A tuple of (deposited_volume, RPM).
- Return type:
- 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)[source]¶
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.
- Parameters:
extruder (ScrewExtruder) – The extruder instance invoking this calculation.
command (Extrude) – The current G-code command.
process_data (AdditiveProcessData) – State data including feed rate and time.
pellet_density (float, optional) – Density of material in kg/m^3. Defaults to 1100.
volumetric_mode (bool, optional) – If True, calculates flow based on bead cross-sectional area. Defaults to False.
- Returns:
A tuple of (RPM, deposited_volume).
- Return type:
- property rpm_coefficients¶
Get the coefficients for the Throughput -> RPM polynomial.
- property throughput_coefficients¶
Get the coefficients for the RPM -> Throughput polynomial.