knitout_to_dat_python.dat_file_structure.Dat_to_Knitout_Converter module

Module containing the Dat_to_Knitout_Converter class.

This module provides functionality to convert Shima Seiki DAT files back into knitout instructions. It handles the complete reverse conversion pipeline including DAT file reading, pixel decoding, instruction reconstruction, and knitout file generation.

class Dat_to_Knitout_Converter(dat_filename: str, pattern_buffer: int = 4)[source]

Bases: object

Class to convert a Shima Seiki Dat file to knitout instructions.

This class provides functionality to read DAT files, parse their pixel data and option lines, and convert them back into equivalent knitout instructions. It handles the complete reverse conversion pipeline including pixel decoding, instruction reconstruction, and knitout file generation.

Parameters:
  • dat_filename (str)

  • pattern_buffer (int, default: 4)

__init__(dat_filename: str, pattern_buffer: int = 4)[source]

Initialize a Dat_to_Knitout_Converter.

Parameters:
  • dat_filename (str) – Path to the input DAT file to convert.

  • pattern_buffer (int, optional) – Buffer space around the pattern. Defaults to 4.

Raises:
  • ValueError – If DAT file format is invalid or cannot be processed.

  • AssertionError – If raster pattern width exceeds expected pattern width.

dat_filename: str

Path to the DAT file being converted.

Type:

str

pixels: list[list[int]]

2D array of pixel values from the DAT file.

Type:

list[list[int]]

expected_pattern_width: int

The expected width of the knitting pattern.

Type:

int

rasters: list[Pixel_Carriage_Pass_Converter]

List of converters for each pixel row.

Type:

list[Pixel_Carriage_Pass_Converter]

process: list[Knitout_Instruction | Carriage_Pass]

The converted knitout process instructions.

Type:

list[Knitout_Instruction | Carriage_Pass]

executed_instructions: list[Knitout_Instruction]

List of individual executed instructions from the process.

Type:

list[Knitout_Instruction]

write_knitout(knitout_filename: str) None[source]

Write the knitout gathered from the dat file to the given knitout filename.

Generates a complete knitout file including machine headers and all converted instructions from the DAT file processing.

Parameters:

knitout_filename (str) – The name of the knitout file to write.

Return type:

None