virtual_knitting_machine.machine_components.carriage_system.Carriage_Pass_Direction module
Enumerator module for possible carriage pass directions on knitting machines.
This module defines the two directions a carriage can move across the needle bed and provides utility functions for needle positioning, comparison, and sorting operations relative to carriage movement direction.
- class Carriage_Pass_Direction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
An enumerator for the two directions the carriage can pass on the knitting machine.
Needles are oriented on the machine left to right in ascending order: Left -> 0 1 2 … N <- Right. This enum provides methods for needle comparison, positioning, and sorting operations relative to carriage movement direction.
- Leftward = '-'
- Rightward = '+'
- opposite()[source]
Get the opposite pass direction of this direction.
- Returns:
The opposite pass direction of this direction.
- Return type:
- __neg__()[source]
Get the opposite direction using unary minus operator.
- Returns:
The opposite pass direction.
- Return type:
- __invert__()[source]
Get the opposite direction using bitwise invert operator.
- Returns:
The opposite pass direction.
- Return type:
- static rightward_needles_comparison(first_needle, second_needle, rack=0, all_needle_rack=False)[source]
Compare two needles for rightward carriage movement ordering.
- Parameters:
- Returns:
1 if first_needle is left of second needle (rightward order), 0 if needles are in equal position at given racking, or -1 if first_needle is right of second needle (leftward order).
- Return type:
- static leftward_needles_comparison(first_needle, second_needle, rack=0, all_needle_rack=False)[source]
Compare two needles for leftward carriage movement ordering.
- Parameters:
- Returns:
-1 if first_needle is to the left of second needle (rightward order), 0 if needles are in equal position at given racking, or 1 if first_needle is right of second needle (leftward order).
- Return type:
- needle_direction_comparison(first_needle, second_needle, rack=0, all_needle_rack=False)[source]
Compare two needles based on their order in this carriage pass direction.
- Parameters:
- Returns:
-1 if first_needle comes after second_needle in pass direction, 0 if needles are at equal alignment given the racking, 1 if first needle comes before second_needle in pass direction.
- Return type:
- needles_are_in_pass_direction(first_needle, second_needle, rack=0, all_needle_rack=False)[source]
Check if the first needle comes before the second needle in the given pass direction.
- Parameters:
- Returns:
True if the first needle comes before the second needle in the given pass direction, False otherwise.
- Return type:
- static get_direction(dir_str)[source]
Return a Pass direction enum given a valid string representation.
- Parameters:
dir_str (str) – String to convert to direction (“-” for Leftward, anything else for Rightward).
- Returns:
Pass direction corresponding to the string.
- Return type:
- __str__()[source]
Return string representation of the carriage pass direction.
- Returns:
String representation of the direction value.
- Return type:
- __repr__()[source]
Return string representation of the carriage pass direction.
- Returns:
String representation of the direction value.
- Return type:
- classmethod __contains__(member)
Return True if member is a member of this enum raises TypeError if member is not an enum member
note: in 3.12 TypeError will no longer be raised, and True will also be returned if member is the value of a member in this enum
- classmethod __getitem__(name)
Return the member matching name.
- classmethod __iter__()
Return members in definition order.
- classmethod __len__()
Return the number of members (no aliases)