virtual_knitting_machine.machine_components.yarn_management.Yarn_Carrier module
Yarn_Carrier representation module for managing individual yarn carriers on knitting machines. This module provides the Yarn_Carrier class which represents a single yarn carrier that can hold yarn, track position, and manage active/hooked states for knitting operations.
- class Yarn_Carrier(carrier_id, yarn=None, yarn_properties=None, knit_graph=None)[source]
Bases:
object
A class representing an individual yarn carrier on a knitting machine. Yarn carriers hold yarn and can be moved to different positions on the machine, activated for knitting operations, and connected to insertion hooks for yarn manipulation. Each carrier tracks its state including position, active status, and hook connection.
- Parameters:
carrier_id (
int
)yarn (
Optional
[Machine_Knit_Yarn
])yarn_properties (
Optional
[Yarn_Properties
])knit_graph (
Optional
[Knit_Graph
])
- __init__(carrier_id, yarn=None, yarn_properties=None, knit_graph=None)[source]
Initialize a yarn carrier with specified ID and optional yarn configuration.
- Parameters:
carrier_id (int) – Unique identifier for this yarn carrier.
yarn (None | Machine_Knit_Yarn, optional) – Existing machine knit yarn to assign to this carrier. Defaults to None.
yarn_properties (Yarn_Properties | None, optional) – Properties for creating new yarn if yarn parameter is None. Defaults to None.
knit_graph (
Optional
[Knit_Graph
])
- property yarn: Machine_Knit_Yarn
Get the yarn held on this carrier.
- Returns:
The yarn held on this carrier.
- Return type:
- property position: None | int
Get the needle position that the carrier sits at or None if inactive.
- Returns:
The needle position that the carrier sits at or None if the carrier is not active.
- Return type:
None | int
- direction_to_needle(needle_position)[source]
- property last_direction: None | Carriage_Pass_Direction
Returns: Carriage_Pass_Direction | None: The last direction that the carrier was moved in or None if the carrier is inactive.
- property conflicting_needle_slot: int | None
Returns: int | None: The needle slot that currently conflicts with the carrier or None if the carrier is not active.
- property needle_range: None | tuple[int, int]
Returns: None | tuple[int, int]: The range of positions that a carrier may exist after an ambiguous movement or None if the carrier is inactive.
- property is_active: bool
Check if the carrier is currently active (off the grippers).
- Returns:
True if carrier is active, False otherwise.
- Return type:
- property is_hooked: bool
Check if the carrier is connected to the insertion hook.
- Returns:
True if connected to inserting hook, False otherwise.
- Return type:
- bring_in()[source]
Record bring-in operation to activate the carrier without using insertion hook.
- Warns:
In_Active_Carrier_Warning – If carrier is already active.
- Return type:
- releasehook()[source]
Record release hook operation to disconnect carrier from insertion hook.
- Return type:
- out()[source]
Record out operation to deactivate the carrier and move to grippers.
- Warns:
Out_Inactive_Carrier_Warning – If carrier is already inactive.
- Return type:
- outhook()[source]
Record outhook operation to cut and remove carrier using insertion hook.
- Raises:
Hooked_Carrier_Exception – If carrier is already connected to yarn inserting hook.
- Return type:
- property carrier_id: int
Get the unique identifier of this carrier.
- Returns:
ID of carrier, corresponds to order in machine.
- Return type:
- __lt__(other)[source]
Compare if this carrier ID is less than another carrier or integer.
- Parameters:
other (int | Yarn_Carrier) – The carrier or integer to compare with.
- Returns:
True if this carrier’s ID is less than the other.
- Return type:
- __eq__(other)[source]
Equality comparison of a carrier to another carrier or object representing a carrier. :type other:
int
|Yarn_Carrier
|Yarn_Carrier_Set
|list
[int
|Yarn_Carrier
] :param other: The carrier or object representing a carrier. :type other: int | Yarn_Carrier | Yarn_Carrier_Set | list[int | Yarn_Carrier]- Returns:
True if this carrier is equal to the other. Carrier sets are equal if they only contain this carrier.
- Return type:
- __hash__()[source]
Return hash value based on carrier ID.
- Returns:
Hash value of the carrier ID.
- Return type:
- __str__()[source]
Return string representation of the carrier.
- Returns:
String representation showing carrier ID and yarn if different from ID.
- Return type: