gcode_reader.preprocess¶
Pre-processes lines of G-code programs to a consistent key-value format.
Terminology Definitions: - Line (Block): The RS-274/NGC language is based on lines of code. Each line (block) may include commands to a machining center to do several different things. Lines of code may be collected in a file to make a program. - Word: A letter other than N followed by a real value. A real value is some collection of characters that can be processed to come up with a number. A real value may be an explicit number (such as 341 or -0.8807), a parameter value, an expression, or a unary operation value. Definitions of these follow immediately. Processing characters to come up with a number is called “evaluating”. An explicit number evaluates to itself. - Parameter: A key-value pair - Expression: A combination of parameters, operators, and values that can be evaluated to produce a result. Expressions can be used to calculate values dynamically based on other variables or conditions.
References: - https://fabricesalvaire.github.io/pythonic-gcode-machine/gcode-reference/rs-274/index.html#format-of-a-line - https://www.nist.gov/publications/nist-rs274ngc-interpreter-version-3
Functions¶
|
Uses syntax definition to identify declaration of named parameters in line. |
|
Inserts the evaluation of a functional expression into the line, such as COS[213], recursively. |
|
Inserts the evaluation of a generic expression into the line, such as [1+1], recursively. |
|
Uses syntax definition to identify named parameters in line. Replaces with values |
|
Determines if G-code line is a modal group. Modal commands are arranged in sets such as "G7 G18 G19" |
|
Module Contents¶
- gcode_reader.preprocess.line_declares_parameters(line: str, named_parameters: dict = {}, flavor: dict = syntax.flavors['default'])[source]¶
Uses syntax definition to identify declaration of named parameters in line.
- Parameters:
- Returns:
Existence of parameter declaration, dictionary of parameters
- Return type:
- gcode_reader.preprocess.line_insert_function_expressions(line, flavor: dict = syntax.flavors['default'])[source]¶
Inserts the evaluation of a functional expression into the line, such as COS[213], recursively. :param line: line (block) for a G-code program :type line: str :param flavor: Syntax definition for line. Defaults to syntax.flavors[“default”]. :type flavor: dict, optional
- Returns:
Modified line
- Return type:
- gcode_reader.preprocess.line_insert_generic_expressions(line: str, flavor: dict = syntax.flavors['default'])[source]¶
Inserts the evaluation of a generic expression into the line, such as [1+1], recursively. :param line: line (block) for a G-code program :type line: str :param flavor: Syntax definition for line. Defaults to syntax.flavors[“default”]. :type flavor: dict, optional
- Returns:
Modified line
- Return type:
- gcode_reader.preprocess.line_insert_parameters(line: str, named_parameters: dict = {}, flavor: dict = syntax.flavors['default'])[source]¶
Uses syntax definition to identify named parameters in line. Replaces with values