knitout_interpreter.knitout_operations.Rack_Instruction module — knitout-interpreter 0.0.18 documentation

# knitout_interpreter.knitout_operations.Rack_Instruction module

Module for the Rack_Instruction class.

class knitout_interpreter.knitout_operations.Rack_Instruction.Rack_Instruction(rack, comment=None)

  Bases: `Knitout_Instruction`

  Instruction for setting the rack alignment between front and back beds.

  property rack: int

    Get the integer value of rack alignment.

    Returns:

      Integer value of rack alignment.

  property all_needle_rack: bool

    Check if rack causes all-needle-knitting alignment.

    Returns:

      True if rack causes all-needle-knitting alignment.

  property rack_value: float

    Get the rack value including all-needle-knitting alignment.

    Returns:

      The value of the rack including all-needle-knitting alignment as float specification.

  __str__()

    Return string representation of the rack instruction.

    Returns:

      String representation showing instruction type, rack value, and comment.

    Return type:

      str

  execute(machine_state)

    Execute the rack instruction on the given machine.

    Parameters:

      machine_state (Knitting_Machine) – The knitting machine to update with the rack instruction.

    Returns:

      True if the machine state was updated, False if no change was needed.

    Return type:

      bool

  static rack_instruction_from_int_specification(rack=0, all_needle_rack=False, comment=None)

    Create a rack instruction from integer specification.

    Note: From Knitout Specification: Number indicating the offset of the front bed relative to the back bed. That is, at racking R, back needle index B is aligned to front needle index B+R. Needles are considered aligned if they can transfer. That is, at racking 2, it is possible to transfer from f3 to b1. May be fractional on some machines. E.g., on Shima machines, 0.25/-0.75 are used for all-needle knitting.

    Parameters:

      - rack (int) – Integer racking value (default 0).

      - all_needle_rack (bool) – Whether to use all-needle knitting alignment (default False).

      - comment (None | str) – Optional comment to include with the instruction.

    Returns:

      Rack instruction configured with the specified parameters.

    Return type:

      Rack_Instruction

  static execute_rack(machine_state, racking, comment=None)

    Execute a rack instruction immediately on the machine.

    Parameters:

      - machine_state (Knitting_Machine) – The current machine model to update.

      - racking (float) – The new racking to set the machine to.

      - comment (str | None) – Additional details to document in the knitout.

    Returns:

      The racking instruction that was executed.

    Return type:

      Rack_Instruction