virtual_knitting_machine.machine_components.carriage_system.Carriage_Snapshot module
A module containing the Carriage Snapshot Class
- class Carriage_Snapshot(carriage, machine_snapshot)[source]
Bases:
Carriage_StateA class used to represent a snapshot of the state of the given carriage at the time of instantiation.
- property knitting_machine: Knitting_Machine_Snapshot
Returns: Knitting_Machine_Snapshot: The knitting machine that owns this carriage.
- property position_on_bed: Needle_Bed_Position
Returns: Needle_Bed_Position: The position of the machine component relative to the needle bed.
- property last_set_direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The direction the carriage was last explicitly moved in (i.e., knits, tucks, splits).
- 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]): ….
- aligned_with_slot(slot)
- Parameters:
slot (int | Slotted_Position) – The slot to compare to.
- Returns:
True if this is positioned at the same slot, False otherwise.
- Return type:
- direction_to_slot(slot)
- Parameters:
slot (int) – The slot to find a direction towards.
- Returns:
The direction of carriage movement from this component to the slot or None if the slots are aligned.
- Return type:
Carriage_Pass_Direction | None
- 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.
- in_pass_direction(slot, direction)
- Parameters:
slot (int | Slotted_Position) – The slot following this slot in a carriage pass movement.
direction (Carriage_Pass_Direction) – The direction to test.
- Returns:
True if the given slot is after this slot in the given direction. False otherwise.
- Return type:
- property last_direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The last direction the object moved in.
- left_of_slot(slot)
- Parameters:
slot (int | Slotted_Position) – The slot to compare to.
- Returns:
True if this is positioned left of the given slot, False otherwise.
- 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.
- 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.
- right_of_slot(slot)
- Parameters:
slot (int | Slotted_Position) – The slot to compare to.
- Returns:
True if this is positioned right of the given slot, False otherwise.
- Return type:
- 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 slot_number: int
The slot number indicates the front-bed alignment of the given needle. For front bed needles this is equivalent to the position. For back bed needles this is dependent on the racking alignment of the beds.
- Returns:
The slot number of the given component for the given racking.
- Return type:
Notes
Racking Calculations: * R = F - B * F = R + B * B = F - R.
- property violation_policy: Knitting_Machine_Error_Policy
Returns: Knitting_Machine_Error_Policy: The policy for handling machine state errors.