gscrib.codes

Maps machine operations to G/M-code commands.

This module contains a table that translates our internal enum values into their corresponding G-Code instructions. The GCodeBuilder class uses this mapping to generate valid G-Code output.

class gscrib.codes.GCodeEntry(enum, instruction, description)

Bases: object

Represents a single G-Code instruction entry.

Parameters:
property description: str

Description of what the G-Code instruction does

property enum: BaseEnum

Enum value associated with this entry.

property instruction: str

G-Code instruction associated with the enum value.

class gscrib.codes.GCodeTable(values)

Bases: object

Mapping table for G-Code instructions.

This class maintains a collection of GCodeEntry objects, providing a way to store and retrieve G-Code instructions and their descriptions based on the internal enum representations. Each entry is uniquely identified by a combination of its enum type and value.

Parameters:

values (Tuple[GCodeEntry, ...])

add_entry(entry)

Add a new entry to the table.

Parameters:

entry (GCodeEntry) – The GCodeEntry to add to the table.

Raises:

KeyError – If an entry for the given enum already exists in the table.

Return type:

None

get_entry(enum)

Retrieve the entry for the given enum.

Parameters:

enum (BaseEnum) – The BaseEnum value to look up.

Returns:

The corresponding entry from the table.

Return type:

GCodeEntry

Raises:

KeyError – If no entry exists for the given enum.