gcode_reader.emulate.operations¶
Classes¶
An Operation specialized for additive processes (e.g., 3D printing). |
|
Stores ProcessData associated with Command execution by a Machine for an additive operation. |
|
Represents a single manufacturing step. |
|
Stores data associated with Command execution by a Machine. |
|
Columnar (struct-of-arrays) view of a List[ProcessData]. |
|
An Operation specialized for subtractive processes (e.g., milling, CNC). |
|
Stores process_data associated with Command execution by a Machine for a subtractive operation. |
Functions¶
|
Return a fresh ProcessData instance appropriate for operation_cls. |
|
Associate an Operation subclass with the ProcessData subclass it produces. |
Module Contents¶
- class gcode_reader.emulate.operations.AdditiveOperation[source]¶
Bases:
OperationAn Operation specialized for additive processes (e.g., 3D printing).
- class gcode_reader.emulate.operations.AdditiveProcessData[source]¶
Bases:
ProcessDataStores ProcessData associated with Command execution by a Machine for an additive operation.
- class gcode_reader.emulate.operations.Operation[source]¶
Represents a single manufacturing step.
Holds sequence of commands and stores the resulting process data after simulation or execution by a machine model.
- name¶
A human-readable name for the operation.
- commands¶
A list of Command objects that define the machine’s actions.
- process_data¶
A list of ProcessData objects, populated after processing, containing detailed information like tool locations and timing.
- processed_by_machine¶
Stores the type of the machine that last processed this operation.
- get_all_locations() numpy.ndarray[source]¶
Gathers all valid (non-None) location coordinates from the process data.
- Returns:
A NumPy array of shape (N, 3) containing the [x, y, z] coordinates for N data points. Returns an empty array if no locations are found.
- get_bounds()[source]¶
Calculates the 3D Axis-aligned bounding box of the operation from its process data.
This method checks if the operation has been processed before attempting to calculate the bounds. A warning is logged if it has not been processed.
- Returns:
((min_x, min_y, min_z), (max_x, max_y, max_z)). Returns None if the operation has not been processed or contains no location data.
- Return type:
A tuple containing the minimum and maximum coordinates
- get_total_elapsed_time() float[source]¶
Calculates the total elapsed time for the operation.
- Returns:
The total elapsed time in seconds as a float.
- process_data_to_numpy_dict(bounds: Tuple[int, int] = None) Dict[str, numpy.ndarray][source]¶
Converts process_data to a dict of NumPy arrays, keyed by attribute name.
- Parameters:
bounds – Optional (start, end) index bounds. Defaults to the full list.
- Returns:
A dict mapping each ProcessData attribute name to a NumPy array. Returns an empty dict if the bounds is zero-length.
- Raises:
TypeError – If bounds is not a tuple/list, or if process_data contains mixed types.
ValueError – If bounds does not have exactly 2 elements.
IndexError – If bounds are out of range.
- property arrays: ProcessDataArrays¶
Columnar view of process_data; built once on first access.
- commands: List[gcode_reader.emulate.commands.Command] = []¶
- motion_profile: List = []¶
- process_data: List[ProcessData] = []¶
- class gcode_reader.emulate.operations.ProcessData[source]¶
Stores data associated with Command execution by a Machine.
- class gcode_reader.emulate.operations.ProcessDataArrays[source]¶
Columnar (struct-of-arrays) view of a List[ProcessData].
Downstream consumers (motion.py, additive_part.py) iterate the object list to extract numpy arrays, paying O(N) Python overhead twice. Building this once after the machine loop lets both consumers read pre-built arrays directly.
Construction is intentionally lazy via from_process_data_list() rather than being built inside the machine loop so that the ProcessData objects (still needed for tool callbacks) remain the primary output.
- classmethod from_process_data_list(process_data: list) ProcessDataArrays[source]¶
Build columnar arrays from a List[ProcessData] in a single pass.
- class gcode_reader.emulate.operations.SubtractiveOperation[source]¶
Bases:
OperationAn Operation specialized for subtractive processes (e.g., milling, CNC).
- class gcode_reader.emulate.operations.SubtractiveProcessData[source]¶
Bases:
ProcessDataStores process_data associated with Command execution by a Machine for a subtractive operation.
- gcode_reader.emulate.operations.make_process_data(operation_cls: type) ProcessData[source]¶
Return a fresh ProcessData instance appropriate for operation_cls.
If operation_cls is not a class registered in the map (e.g. a caller accidentally passed an instance), falls back to a plain
ProcessData.
- gcode_reader.emulate.operations.register_process_data(operation_cls: type, process_data_cls: type) None[source]¶
Associate an Operation subclass with the ProcessData subclass it produces.
- Parameters:
operation_cls – The Operation subclass (e.g. AdditiveOperation).
process_data_cls – The ProcessData subclass to instantiate for it.