virtual_knitting_machine.machine_components.yarn_management.Yarn_Insertion_System module
A module containing Yarn Insertion System classes for managing yarn carriers on knitting machines. This module provides the Yarn_Insertion_System class which manages the complete yarn carrier system including carrier states, insertion hook operations, position tracking, and loop creation operations.
- class Yarn_Insertion_System(knitting_machine, carrier_count=10)[source]
Bases:
object
A class for managing the complete state of the yarn insertion system including all yarn carriers on the knitting machine. This system handles carrier positioning, activation states, insertion hook operations, and coordinates loop creation across multiple carriers. It provides comprehensive management of yarn carrier operations including bring-in, hook operations, and float management.
- knitting_machine
The knitting machine this system belongs to.
- Type:
- carriers
The list of yarn carriers in this insertion system. The carriers are ordered from 1 to the number of carriers in the system.
- Type:
- Parameters:
knitting_machine (
Knitting_Machine
)carrier_count (
int
)
- __init__(knitting_machine, carrier_count=10)[source]
Initialize the yarn insertion system with specified number of carriers.
- Parameters:
knitting_machine (Knitting_Machine) – The knitting machine this system belongs to.
carrier_count (int, optional) – Number of yarn carriers to create. Defaults to 10.
- property hook_input_direction: None | Carriage_Pass_Direction
Returns: None | Carriage_Pass_Direction: The direction that the carrier was moving when the yarn-inserting hook was use. None if the yarn-inserting hook is not active.
- property hooked_carrier: Yarn_Carrier | None
Returns: (Yarn_Carrier | None): The yarn-carrier currently on the yarn-inserting-hook or None if the hook is not active.
- property searching_for_position: bool
Check if the inserting hook is active but at an undefined position.
- Returns:
True if the inserting hook is active but at an undefined position, False otherwise.
- Return type:
- position_carrier(carrier_id, position, direction=None)[source]
Update the position of a specific carrier.
- Parameters:
carrier_id (int | Yarn_Carrier) – The carrier to update.
position (int | Needle | None) – The position of the carrier.
direction (Carriage_Pass_Direction, optional) – The direction of the carrier movement. If this is not provided, the direction will be inferred.
- Return type:
- property inserting_hook_available: bool
Check if the yarn inserting hook can be used.
- Returns:
True if the yarn inserting hook can be used, False if in use.
- Return type:
- property active_carriers: set[Yarn_Carrier]
Get set of carriers that are currently active (off the grippers).
- Returns:
Set of carriers that are currently active (off the grippers).
- Return type:
- conflicts_with_inserting_hook(needle_position)[source]
Check if a needle position conflicts with the inserting hook position.
- Parameters:
needle_position (Needle | int | None) – The needle position to check for compliance, or None if the position is moving a carrier off the machine.
- Returns:
True if inserting hook conflicts with a needle slot because the slot is to the right of the hook’s current position. False otherwise.
- Return type:
- missing_carriers(carrier_ids)[source]
Get list of carrier IDs that are not currently active.
- Parameters:
carrier_ids (list[int | Yarn_Carrier]) – The carrier set to check for the inactive carriers.
- Returns:
List of carrier ids that are not active (i.e., on grippers).
- Return type:
- is_active(carrier_ids)[source]
Check if all carriers in the given set are active (not on the gripper).
- Parameters:
carrier_ids (list[int | Yarn_Carrier]) – List of carrier IDs to check.
- Returns:
True if all carriers in set are active (not-on the gripper), Note: If an empty list of carriers is given, this will return true because the empty set is active.
- Return type:
- yarn_is_loose(carrier_id)[source]
Check if yarn in carrier is loose (not on the inserting hook or tuck/knit on bed).
- Parameters:
carrier_id (int | Yarn_Carrier) – The carrier to check for loose yarn.
- Returns:
True if any yarn in yarn carrier set is loose (not on the inserting hook or tuck/knit on bed), False otherwise.
- Return type:
- bring_in(carrier_id)[source]
Bring in a yarn carrier without insertion hook (tail to gripper), yarn is considered loose until knit.
- Parameters:
carrier_id (int | Yarn_Carrier) – Carrier ID to bring in.
- Warns:
In_Active_Carrier_Warning – If carrier is already active.
In_Loose_Carrier_Warning – If carrier yarn is loose (not connected).
- Return type:
- inhook(carrier_id)[source]
Bring a yarn in with insertion hook, yarn is not loose after this operation.
- Parameters:
carrier_id (int | Yarn_Carrier) – Carriers to bring in by id.
- Raises:
Inserting_Hook_In_Use_Exception – If insertion hook is already in use by another carrier.
- Warns:
In_Active_Carrier_Warning – If carrier is already active.
- Return type:
- releasehook()[source]
Release the yarn inserting hook from whatever carrier is currently using it.
- Return type:
- out(carrier_id)[source]
Move carrier to gripper, removing it from action but does not cut it loose.
- Parameters:
carrier_id (int | Yarn_Carrier) – Carrier ID to move out.
- Raises:
Hooked_Carrier_Exception – If carrier is currently connected to insertion hook.
- Warns:
Out_Inactive_Carrier_Warning – If carrier is already inactive.
- Return type:
- outhook(carrier_id)[source]
Cut carrier yarn and move it to grippers with insertion hook, the carrier will no longer be active and is now loose.
- Parameters:
carrier_id (int | Yarn_Carrier) – Carrier ID to cut and move out.
- Raises:
Inserting_Hook_In_Use_Exception – If insertion hook is not available.
Hooked_Carrier_Exception – If carrier is already connected to insertion hook.
- Warns:
Out_Inactive_Carrier_Warning – If carrier is already inactive.
- Return type:
- active_floats()[source]
Get dictionary of all active floats from all carriers in the system.
- Returns:
Dictionary of loops that are active keyed to active yarn-wise neighbors, each key-value pair represents a directed float where k comes before v on the yarns in the system.
- Return type:
- make_loops(carrier_ids, needle, direction)[source]
Create loops using specified carriers on a needle, handling insertion hook positioning and float management.
- Parameters:
carrier_ids (list[int | Yarn_Carrier] | Yarn_Carrier_Set) – The carriers to make the loops with on this needle.
needle (Needle) – The needle to make the loops on.
direction (Carriage_Pass_Direction) – The carriage direction for this operation.
- Returns:
The set of loops made on this machine.
- Return type:
- Raises:
Use_Inactive_Carrier_Exception – If attempting to use an inactive carrier for loop creation.
- __getitem__(item)[source]
Get carrier(s) by ID, carrier object, carrier set, or list of IDs/carriers.
- Parameters:
item (int | Yarn_Carrier | Yarn_Carrier_Set | list[int | Yarn_Carrier]) – The identifier(s) for the carrier(s) to retrieve.
- Returns:
Single carrier or list of carriers corresponding to the input.
- Return type:
- Raises:
KeyError – If invalid carrier ID is provided or carrier index is out of range.