knitout_to_dat_python.kickback_injection.kickback_execution module

Subclass of Knitout_Executer that introduces kickbacks for carrier management when creating Dat files.

This module provides enhanced knitout execution with automatic kickback injection for carrier management. It prevents carrier conflicts by automatically inserting kick instructions to move carriers out of the way of incoming carriage passes, ensuring smooth operation during DAT file generation.

class Negative_Kick_Instruction(position: int, direction: str | Carriage_Pass_Direction, cs: Yarn_Carrier_Set | None = None, comment: None | str = None)[source]

Bases: Kick_Instruction

A subclass of the Kick_Instruction used to undo the negative needle requirement TODO: Remove this requirement from the original Kick_Instruction class.

Parameters:
  • position (int)

  • direction (str | Carriage_Pass_Direction)

  • cs (Optional[Yarn_Carrier_Set], default: None)

  • comment (Optional[str], default: None)

__init__(position: int, direction: str | Carriage_Pass_Direction, cs: Yarn_Carrier_Set | None = None, comment: None | str = None)[source]

Initialize a kick instruction for a specific needle position.

Parameters:
  • position (int) – The needle position for the kickback.

  • direction (str | Carriage_Pass_Direction) – The direction of the carriage pass.

  • cs (Optional[Yarn_Carrier_Set], default: None) – The yarn carrier set to use. Defaults to None.

  • comment (Optional[str], default: None) – Optional comment for the instruction. Defaults to None.

class Knitout_Executer_With_Kickbacks(instructions: list[Knitout_Line], knitting_machine: Knitting_Machine)[source]

Bases: Knitout_Executer

Subclass of the Knitout_Executer that introduces kickback logic for carrier management before each carriage pass.

This class extends the standard Knitout_Executer to automatically inject kick instructions that prevent carrier conflicts during knitting operations. It tracks carrier positions, manages carrier buffers, and generates appropriate kickback sequences to ensure carriers don’t interfere with carriage pass execution.

process

The processed instruction list including injected kickbacks.

Type:

list[Knitout_Line | Carriage_Pass]

executed_instructions

The list of executed instruction lines.

Type:

list[Knitout_Line]

kickback_machine

Separate machine instance for tracking kickback state.

Type:

Knitting_Machine

_last_carrier_movement

The most recent carriage pass that involved carrier movement.

Type:

Carriage_Pass | None

Parameters:
  • instructions (list[Knitout_Line])

  • knitting_machine (Knitting_Machine)

__init__(instructions: list[Knitout_Line], knitting_machine: Knitting_Machine)[source]

Initialize a Knitout_Executer_With_Kickbacks.

Creates an enhanced knitout executor that automatically manages carrier conflicts through kickback injection. Sets up carrier tracking systems and processes the instruction list with automatic conflict resolution.

Parameters:
  • instructions (list[Knitout_Line]) – The list of knitout instructions to execute.

  • knitting_machine (Knitting_Machine) – The knitting machine to execute instructions on.

get_carriers(carrier_set: Yarn_Carrier_Set | None) set[Yarn_Carrier][source]
Parameters:

carrier_set (Yarn_Carrier_Set | None) – Yarn carrier set to get carriers from. If this is None, the empty set is returned.

Returns:

The set of yarn carriers from the kickback machine involved in the given carrier set.

Return type:

set[Yarn_Carrier]

add_kickbacks_to_process() None[source]

Rerun the executor’s process but add kickback logic to form a new kickback program.

Processes the original instruction list and automatically injects kick instructions to prevent carrier conflicts. Manages carrier state tracking, conflict detection, and kickback generation throughout the execution process.

Return type:

None