knit_script.knit_script_interpreter.statements.Carriage_Pass_Specification module
Used to manage all instruction sets written for a single carriage pass in a given direction.
This module provides the Carriage_Pass_Specification class, which coordinates the execution of multiple knitting operations that occur during a single pass of the carriage across the needle bed. It ensures proper sequencing, compatibility checking, and execution of operations while handling complex scenarios like all-needle operations and drop pass separation.
- class Carriage_Pass_Specification(source_statement, needle_to_instruction, direction=None, target_bed=None, racking=None, to_sliders=False, is_drop_pass=False)[source]
Bases:
object
Manages actions on a collection of needles in a carriage pass.
This class coordinates the execution of multiple knitting operations that occur during a single pass of the carriage across the needle bed, ensuring proper sequencing and compatibility of operations. It handles complex scenarios including instruction compatibility checking, needle ordering, all-needle racking requirements, and drop operation separation.
- The carriage pass specification ensures that all operations within a single pass are physically possible on the knitting machine
and executes them in the correct order based on the carriage direction and machine racking configuration.
- _source_statement
The source statement that generates this specification.
- Type:
- _target_bed
Target bed filter for operations.
- Type:
Machine_Bed_Position | None
- _drop_pass
Separate drop pass specification.
- Type:
Carriage_Pass_Specification | None
- _needle_to_instruction
Mapping of needles to instructions.
- Type:
dict[Needle, Knitout_Instruction_Type]
- _direction
Direction of the carriage pass.
- Type:
Carriage_Pass_Direction | None
- Parameters:
source_statement (
KS_Element
)needle_to_instruction (
dict
[Needle
,Knitout_Instruction_Type
])direction (
Carriage_Pass_Direction
|None
)target_bed (
Machine_Bed_Position
|None
)to_sliders (
bool
)is_drop_pass (
bool
)
- __init__(source_statement, needle_to_instruction, direction=None, target_bed=None, racking=None, to_sliders=False, is_drop_pass=False)[source]
Initialize a carriage pass specification.
Creates a carriage pass specification with the given instructions and validates compatibility between all operations. Automatically separates drop operations into a dedicated drop pass if other operations are present.
- Parameters:
source_statement (KS_Element) – The source statement that generates this specification for error reporting.
needle_to_instruction (dict[Needle, Knitout_Instruction_Type]) – Dictionary mapping needles to the instructions to perform on them during this pass.
direction (Carriage_Pass_Direction | None, optional) – The direction of the carriage pass. If None, will be determined automatically based on context. Defaults to None.
target_bed (Machine_Bed_Position | None, optional) – If specified, only operations on this bed will be performed. Defaults to None.
racking (float | None, optional) – The racking position for this pass. If None, uses current racking from context. Defaults to None.
to_sliders (bool, optional) – True if transferring or splitting operations target slider needles. Defaults to False.
is_drop_pass (bool, optional) – True if this is a specialized drop-only pass. Defaults to False.
- Raises:
Incompatible_In_Carriage_Pass_Exception – If incompatible instruction types are specified for the same pass.
Required_Direction_Exception – If a direction-dependent instruction is specified without providing a direction.
- write_knitout(context)[source]
Execute machine pass instructions and write to knitout.
Executes all operations in the carriage pass, handling proper needle ordering, racking adjustments, all-needle operations, and drop pass coordination. Generates the appropriate knitout instructions and updates the machine state accordingly.
- Parameters:
context (Knit_Script_Context) – The knit pass context to execute operations on.
- Returns:
Dictionary mapping each needle to its target needle (for transfers/splits) or None for other operations.
- Return type:
dict[Needle, Needle | None]
- Raises:
Repeated_Needle_Exception – If the same needle position is used multiple times in incompatible ways during the pass.
All_Needle_Operation_Exception – If all-needle operations are attempted on overlapping needles without proper racking configuration.