G-code based program Translation and Interpretation

Interpretation of the text of NC code.

Until the NC code frames run out or the interpreter library sets the end of program (INCT_Interpreter.EndOfProgram method), SprutCAM X will read the control program frames and perform the following steps for each frame:

  • Transmission of the frame of the NC code (frame analysis for familiar constructions - objects for interpretation);

  • If a frame translation resulted in at least one object in the list of objects in the current frame for interpretation (the list of objects for INCT_BlockExecArray is not empty), then each object from the INCT_BlockExecArray list is interpreted sequentially;

  • The list of objects in the current frame for interpretation is cleared.


Broadcast of NC code frame.

Until the frame symbols have run out, SprutCAM X performs the following steps:

  • Transfer the interpreter library to the raw part of the frame (the entire frame will be transferred in the first step). In response SprutCAM X expects to receive the number of characters from the beginning of the string passed to interpreter recognized as a single word, or other intelligible interpreter structure (INCT_Interpreter.TransLine method). Recognized characters are considered processed and remove from the frame. This step will be repeated until the interpreter recognizes the sense constructions (words) at the beginning of the remaining frame, i.e. return to SprutCAM X the number of recognized characters greater than zero, or the frame does not end.

  • As soon as the interpreter could not recognize the meaning structure from the beginning of the remaining frame, SprutCAM X tries to determine the register and its value according to the algorithm described in this article.

  • If a register has been defined, it will be added to the end of the list of objects to interpret the current frame (INCT_BlockExecArray, with a register sign). Otherwise, the read and unrecognized part of the frame will be skipped, but it will also be considered processed and removed from the beginning of the remaining frame;


Note.

To recognize the semantic frame structures, where possible, be sure to use the definitions and values of SprutCAM X registers mechanism (Algorithm for determining the register and values ​​in the G-code block). And in the interpreter (in the INCT_Interpreter.TransLine method) to process only those constructions that are impossible or inefficiently recognized by the SprutCAM X mechanism. In this case, the routine work on the definition of typical constructions will be performed by the core of SprutCAM X, the interpreter will process rare cases of semantic constructions that do not fit into the general rules of the algorithm.


Note.

After the interpreter has recognized a word or a semantic construction, it can independently remember information about it (using its internal data structures) or use a list of objects to interpret the current frame (INCT_BlockExecArray). I.e. add to list your item with a feature of the object or register. We recommend using the second option, in this case, the order of objects in the frame will be preserved, regardless of how the object was defined: SprutCAM X core or interpreter.


Interpreting list objects for interpretation consists of the following steps:

  • Before interpreting the list of objects, the INCT_Interpreter.BeforeInterprete method is called, it informs the interpreter about the beginning of the process of interpreting of the current block;

  • For each element of the list, if it does not have the IsUsed flag set and the end of translation flag (INCT_Interpreter.EndOfProgram) is not set, the INCT_Interpreter.Interprete method is executed. Then the interpreted element of the list is set to IsUsed;

  • After interpreting the entire list of objects, the INCT_Interpreter.AfterInterprete method is called, it informs the interpreter about the completion of the process of interpreting the current block;


Note.

When executing the INCT_Interpreter.Interprete method, the interpreter must determine its type by the transferred object and add the corresponding command to the list of CLDATA commands.

For Fanuc machine. For example, if the transferred object is a register with address F (feed), then you need to execute the INCT_CLData.OutFeed method, passing the register value as a parameter.