virtual_knitting_machine.machine_components.yarn_management.Yarn_Insertion_System_Snapshot module
Module containing Yarn Insertion System Snapshot class
- class Yarn_Insertion_System_Snapshot(yarn_insertion_system, machine_snapshot)[source]
Bases:
Yarn_Insertion_System_State[Machine_LoopT,Yarn_Carrier_Snapshot]A snapshot of a given Yarn Insertion System at the time of instance creation.
- _carriers
The list of carrier snapshots at the time of this snapshot.
- Type:
- property yarn_insertion_system: Yarn_Insertion_System[Machine_LoopT]
Returns: Yarn_Insertion_System: The Yarn Insertion System this snapshot was taken from.
- property knitting_machine: Knitting_Machine_Snapshot[Machine_LoopT]
Returns: Knitting_Machine_Snapshot: The knitting machine snapshot that this system belongs to.
- property carriers: list[Yarn_Carrier_Snapshot[Machine_LoopT]]
Returns: list[Yarn_Carrier_Snapshot]: The list of yarn carriers in this insertion system. The carriers are ordered from 1 to the number of carriers in the system.
- property hook_position: int | None
- Returns:
The needle slot of the yarn-insertion hook or None if the yarn-insertion hook is not active.
- Return type:
None | int
Notes
The hook position will be None if its exact position is to the right of the edge of the knitting machine bed.
- property hook_input_direction: Carriage_Pass_Direction | None
Returns: Carriage_Pass_Direction | None: 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_Snapshot[Machine_LoopT] | None
Returns: (Yarn_Carrier_Snapshot | None): The snapshot of the yarn-carrier that was on the yarn-inserting-hook or None if the hook was not active.
- property searching_for_position: bool
Returns: bool: True if the inserting hook is active but at an undefined position, False otherwise.
- property active_floats: dict[Machine_LoopT, Machine_LoopT]
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:
- classmethod __class_getitem__(params)
Parameterizes a generic class.
At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.
However, note that this method is also called when defining generic classes in the first place with class Foo(Generic[T]): ….
- __contains__(item)
- Parameters:
item (int | Yarn_Carrier_State | Sequence[int | Yarn_Carrier_State]) – The carrier, carrier id, or sequence of carriers to search for in carriers in this yarn insertion system.
- Returns:
True if all the given carriers are in the yarn insertion system. False otherwise.
- Return type:
- __getitem__(item)
Get carrier(s) by ID, carrier object, carrier set, or list of IDs/carriers.
- Parameters:
item (int | Yarn_Carrier | slice | Sequence[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.
- property active_carriers: set[Carrier_State_Type]
Returns: set[Yarn_Carrier_State]: Set of carriers that are currently active (off the grippers).
- conflicts_with_inserting_hook(needle)
Check if a needle position conflicts with the inserting hook position.
- Parameters:
needle (Needle_Specification) – The needle-position to check for compliance.
- 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:
- handle_violations(response_policy=None, handler=None)
Context manager that catches exceptions and routes them through the violation policy.
- Parameters:
response_policy (ViolationResponse | Violation, optional) – The ViolationResponse policy for this code block. If given a Violation, the response will be the policy assigned to that violation in the violation policy. Defaults to the response will be the default response of the violation policy.
handler (Callable[..., Any], optional) – Optional handler to attempt before falling back to the policy response.
- 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:
- is_active(carrier_ids)
Check if all carriers in the given set are active (not on the gripper).
- Parameters:
carrier_ids (Sequence[int | Yarn_Carrier_State]) – 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:
- property machine_is_all_needle_racked: bool
Returns: bool: True if the knitting machine is racked for all needle knitting.
- property machine_specification: Knitting_Machine_Specification[Machine_LoopT]
Returns: Knitting_Machine_Specification[Machine_LoopT]: The machine specification of the machine associated with this component.
- missing_carriers(carrier_ids)
- Parameters:
carrier_ids (Sequence[int | Yarn_Carrier_State]) – The carrier set to check for the inactive carriers.
- Returns:
List of carrier ids that are not active (i.e., on grippers).
- Return type:
- property needle_count_of_machine: int
Returns: int: The number of needles on each bed of the knitting machine. Defaults to the bed size in the knitting machine specification.
- property rightmost_slot_on_machine: int
Returns: int: The rightmost slot on this knitting machine. Defaults to the standard bed size in the knitting machine specification.
- set_response_for(violation, response=None)
Sets the response for the given violation to the given response.
- Parameters:
violation (Violation) – The violation to set the response for.
response (ViolationResponse, optional) – The response to set for the given violation. Defaults to the default response of this policy.
- property violation_policy: Knitting_Machine_Error_Policy
Returns: Knitting_Machine_Error_Policy: The policy for handling machine state errors.
- yarn_is_loose(carrier_id)
- Parameters:
carrier_id (int | Yarn_Carrier_State) – 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: