Interpreter interface
INCT_Interpreter - the interface that must be implemented in the interpreter library. The interpreter library returns to the CAM system an object implementing this interface as the result of the NCT_GetInterface function call. Through this interface the CAM system interacts with the interpreter at all stages of interpreting the NC program text.
Description of the interface methods:
| Method | Method description | Description of use |
|---|---|---|
| GetIdentifier | The function must return to the CAM system a string with the identifier of the interpreter library. No input parameters. | When the interpreter is loaded into memory, the CAM system calls the GetIdentifier function and expects to receive the identifier of the interpreter library. Then the CAM system compares it with the library identifier from the interpreter settings file; if the identifiers match, it continues the loading process. |
| GetRegisters | The function must return to the CAM system the INCT_RegisterList interface, which implements the list of interpreter registers. No input parameters. | When the interpreter is loaded into memory, the CAM system calls the GetRegisters function and expects to receive the list of interpreter registers, then calls this function for the parents of the interpreter. As a result, the CAM system forms a common list of registers taking inheritance into account. |
| SetInterface | The method must receive and, if the interpreter needs it, save the interfaces passed from the CAM system for later use. The method is called several times: once for each passed interface. Input parameter: Intf (IUnknown interface). No output parameters. | When the interpreter is initialized, the CAM system passes its interfaces to the interpreter library one by one using the SetInterface method. The passed interfaces can be used when interpreting the NC program text and provide access to:
|
| Initialize | The method informs the interpreter that all CAM system interfaces have been passed and the interpreter can be initialized. No input parameters. No output parameters. | At the end of the interpreter initialization, the CAM system calls the Initialize method. The call informs the interpreter that all CAM system interfaces have been passed, and the interpreter can perform the actions needed for initialization (for example, get the numbers of the machine axes). |
| NextOperation | The method informs the interpreter that interpretation of the next operation begins. No input parameters. No output parameters. | The CAM system calls this method before interpreting each operation. The interpreter can perform the necessary actions (for example, initialize internal variables, set the order of processing the NC programs of the operation). |
| TransLine | The method passes to the interpreter an NC program block (or a part of the block, depending on the current iteration of the block translation) to try to read a token or a semantic construction from its beginning. If the interpreter has recognized a token or a construction, it must return the number of characters from the beginning of the string that make up the recognized token or construction. Otherwise, it returns 0. Input parameter: CurrentLine (string) - the passed block or part of the block. Output parameters:
| During the translation of an NC program block, the CAM system lets the interpreter recognize a token or a semantic construction at the beginning of the current block. To do this, the CAM system calls the TransLine method of the interpreter and passes it the current block in the CurrentLine input parameter. In response, the interpreter must return in the ProcessedChars parameter the number of characters from the beginning of the passed string that make up the token or semantic construction, if it has been recognized. Otherwise, if the token or construction has not been recognized, the interpreter returns 0. If the interpreter has recognized a token or semantic construction, it is removed from the current string CurrentLine, and the string is passed to the interpreter again by calling the TransLine method to try to read the next token or semantic construction. If the interpreter has not recognized a token or semantic construction, the CAM system tries to determine the register and its value by the algorithm described in this article. After that, all the read characters are removed from the CurrentLine string, and the string is passed to the interpreter by calling the TransLine method to try to read the next token or semantic construction. The process continues until the end of the string or until the BreakLine parameter becomes True. If after the TransLine call the BreakLine output parameter is True, the translation of the current block stops, and the CAM system interprets the translated part of the block. That is, the INCT_BlockExecArray formed by this moment is interpreted. If after the TransLine call the NextLine output parameter is True, then after the translation of the current block is completed, the CAM system reads and translates the next NC program block without interpreting the current block. The INCT_BlockExecArray formed by the translation of the current block is not cleared and is supplemented with the objects created during the translation of the next block. When the translation of the next line is completed and the NextLine parameter has not become True again, the INCT_BlockExecArray accumulated by the translation of the two blocks is interpreted. If the NextLine parameter is True again, then after the translation of the second block is completed, the CAM system reads and translates the third block, and so on. |
| DefineRegister | The function must search for a register by address, return the search result and the index of the found register. Input parameter: Addr (string) - the register address. Output parameter: Index (integer) - the index of the found register. Result (boolean): True - the register is found, False - not found. | When reading a token, the CAM system tries to determine the register in the set of characters read from the NC program block. To do this, the CAM system calls the DefineRegister function of the interpreter interface and passes the read set of characters as the register address Addr. If the interpreter answers positively, the register is considered determined, and its index is contained in the Index output parameter. If the interpreter answers negatively, the CAM system tries to find the register by the address in the list of registers. When implementing the function (INCT_Interpreter.DefineRegister), it is recommended to search for and determine only those registers that the CAM system kernel cannot determine unambiguously. In other cases, do not search and return a negative result. |
| BeforeInterprete | The method informs the interpreter that the translation of the current block is finished and its interpretation begins. No input parameters. No output parameters. | Before the interpretation of the current NC program block, the CAM system calls the BeforeInterprete method of the interpreter. The method is intended to initialize the variables and objects related to the current block, if necessary. |
| Interprete | The method passes to the interpreter the number of an element from the list of objects to interpret of the current block. The interpreter must interpret the passed object, that is, determine its type by the object number and, if necessary, add a command to form the tool path element(s) to INCT_CLData. Input parameter: ExecNum (integer) - the number of the element in the list of objects to interpret (INCT_BlockExecArray). No output parameters. | During the interpretation of the current NC program block, if the INCT_BlockExecArray list is not empty, the CAM system calls the Interprete method for each object of the list in turn. The method is intended to interpret an object from the list, that is, to form a tool path element from the previously translated object. Example for the Fanuc controller. If the passed object is a register with the address F (feed), then to change the feed of the current tool path, call the INCT_CLData.OutFeed method and pass the register value as the feed parameter. |
| AfterInterprete | The method informs the interpreter that the interpretation of the current block is finished. No input parameters. No output parameters. | After the interpretation of the current NC program block, the CAM system calls the AfterInterprete method of the interpreter. The method is intended to free the memory taken by the variables and objects related to the processed block, if necessary. |
| EndOfProgram | The function must return to the CAM system the end of program flag if a program end command was processed during the interpretation of the NC program text. The translation and interpretation of the NC program then stop. No input parameters. Result (boolean): True - the program has ended. | Before each call of the Interprete method, the CAM system calls the EndOfProgram function. If the function returns True, the interpretation of the current block and the translation of the rest of the NC program text stop. |