Control Emulator Functions

Control emulator functions are specific for use by CERUN. Control emulator functions all start with “$FCE…”. These functions cannot be called from post-processor or model macros.

The $FCEADD Function

\textbf{{\char36}FCEADD}\textbf{(}\icamhsp{0.707mm}\mathit{code}\icamhsp{0.707mm}\textbf{)}

Add a CODE identifier to the current block

Returns: Logical

\textbf{{\char36}FCEADD}\textbf{(}\icamhsp{0.707mm}\mathit{data}\,\bigl[,\mathit{value}\,\bigr]\icamhsp{0.707mm}\textbf{)}

Add a DATA identifier and associated value to the current block

Returns: Logical

Use the $FCEADD function to add a code identifier to the current block and/or to add a data identifier and its associated numeric value to the current block. The $FCEADD function differs from the EXEC command in that its actions apply to the current MCD block being processed, whereas the EXEC either inserts new blocks in front of the current block or appends new blocks after the current block.

This function returns a value of $TRUE if the code or data identifier was added. A value of $FALSE is returned if the code or data identifier could not be added to the current block.

The $FCEADD function must not be called in a startup macro since the block has yet to be broken down into its identifier components, nor is it useful to call this function in any shutdown macro since at that point all processing of identifiers has been completed.

The $FCEDAC Function

\textbf{{\char36}FCEDAC}\textbf{(}\icamhsp{0.707mm}\mathit{data}\,\bigl[,\mathit{group}\,\bigr]\icamhsp{0.707mm}\textbf{)}

Associate a DATA identifier with a code group number

Returns: Logical

The $FCEDAC function (meaning Data As Code) is used to allow a data identifier to fire actions without the explicit need for a code definition. By associating a specific data identifier to a code group number, an MCD block containing this data identifier will fire the current modal code from the group; provided that there is no other code from that same group already queued for processing on the block.

The group parameter can be omitted, or set to –1, in order to remove the association of the data identifier with a code group.

The $FCEGAC Function

\textbf{{\char36}FCEGAC}\textbf{(}\icamhsp{0.707mm}\mathit{code}\icamhsp{0.707mm}\textbf{)}

Get active CODE from code group

Returns: CODE Identifier

The $FCEGAC function returns the currently active code from the code group to which the specified code identifier belongs. Code groups are defined in the QUEST “Code Customization”. If the specified code is non-modal or not enabled, then a special code value of CODE_NONE is returned.

The $FCEGET Function

\textbf{{\char36}FCEGET}\textbf{(}\icamhsp{0.707mm}\mathit{id}\icamhsp{0.707mm}\textbf{)}

Get and remove a CODE or DATA identifier from the current block

Returns: Numeric or $NULL

The $FCEGET function is used to get and remove either a code or data identifier id from the current block. Use the $FCESEEK function instead to get the value of a code or data identifier without removing it from the current block. To replace a code or data identifier on a block, first call $FCEGET to remove the old identifier and then call $FCEADD to add the new identifier.

If the code or data identifier is found on the current block, then the $FCEGET function returns the value associated with the code or data identifier (or zero) and the identifier is then removed from the block. A value of $NULL is returned if the code or data identifier is not found.

The $FCEGET function must not be called in a startup macro since the block has yet to be broken down into its identifier components, nor is it useful to call this function in any shutdown macro since at that point all processing of identifiers has been completed.

The $FCEGNCV Function

\textbf{{\char36}FCEGNCV}\textbf{(}\icamhsp{0.707mm}\mathtt{\char39}\mathit{var}\,\mathtt{\char39}\biggl[,\mathit{n_{1}}\Bigl[,\mathit{n_{2}}\,\bigl[,\mathit{n_{3}}\,\bigr]\,\Bigr]\,\biggr]\icamhsp{0.707mm}\textbf{)}

Get and remove a CODE or DATA identifier from the current block

Returns: Numeric, Logical, String or $NULL

The pre-processor has logic to identify and process MCD that sets the value of CNC variables, so that it can later replace any use of a variable in the MCD with its actual value. The $FCEGNCV function can be used if it is necessary to obtain the value of a CNC variable previously identified by the pre-processor. The variable must be specified in its native CNC format using the string var. If the variable represents a single, double or triple dimensioned table, then the table indices n1, n2 and n3 can be specified. Alternately, the variable definition var can include the proper CNC notation to de-reference the array or table cell instead of providing the indices as arguments.

The $FCEGNCV function returns the numeric, logical or string value of the CNC variable specified. The special constant $NULL will be returned if the CNC variable is not defined or if a pre-processor is not in use.

The $FCEPP Function

\textbf{{\char36}FCEPP}\textbf{(}\icamhsp{0.707mm}\ldots\icamhsp{0.707mm}\textbf{)}

Pre-processor specific communications

Returns: Any

The $FCEPP function is used for communication with the pre-processor. The arguments and return values are unique to each pre-processor.

The $FCERST Function

\textbf{{\char36}FCERST}\textbf{(}\icamhsp{0.707mm}\mathtt{\char39}\mathit{file}\,\mathtt{\char39}\Bigl[,\mathit{line}\,\bigl[,\mathit{reset}\,\bigr]\,\Bigr]\icamhsp{0.707mm}\textbf{)}

Select the next NC program file for processing

Returns: Logical

The $FCERST function is used to process NC programs that have been fragmented into multiple files. This function can only be called from the machine shutdown macro, and causes a restart when the shutdown macro completes. The next program file will be used on the restart. Reading will start at the specified line number (default is line 1) of the new file. Specify $TRUE for the optional reset parameter to reset processing as though this was the first NC program file in the series. This function returns $TRUE if successful or $FALSE if it failed and a diagnostic was generated.

The $FCESAC Function

\textbf{{\char36}FCESAC}\textbf{(}\icamhsp{0.707mm}\mathit{code}\icamhsp{0.707mm}\textbf{)}

Set active CODE in code group

Returns: CODE Identifier

The $FCESAC function sets the specified code identifier as the currently active code of the code group to which the specified identifier belongs. Code groups are defined in the QUEST “Code Customization”. The $FCESAC function returns the code that was previously active. If the specified code is non-modal or not enabled, then a special code value of CODE_NONE is returned instead.

The $FCESEEK Function

\textbf{{\char36}FCESEEK}\textbf{(}\icamhsp{0.707mm}\mathit{code}\icamhsp{0.707mm}\textbf{)}

Get a CODE identifier

Returns: Numeric or $NULL

\textbf{{\char36}FCESEEK}\textbf{(}\icamhsp{0.707mm}\mathit{data}\,\bigl[,\mathit{type}\,\bigr]\icamhsp{0.707mm}\textbf{)}

Get a DATA identifier

Returns: Numeric or $NULL

The first form of the $FCESEEK function is used to test for the presence of the specified code identifier on the current MCD block, without removing the code from the block. If the specified code is found, the code value (or zero) will be returned. If the code is not present on the current block, then a value of $NULL is returned.

The second form of the $FCESEEK function is used to test for the presence of the specified data identifier on the current or an earlier MCD block. The optional type keyword defines the scoping rules that are used when looking for the data identifier. Omit the type keyword to restrict the search to the current MCD block only. Specify MODAL to search first on the current MCD block and if not found, then return the modal value of the data identifier. Specify LAST to return the modal value of the data identifier excluding any value that might be coded on the current MCD block. The MODAL and LAST keywords are only applicable to data identifiers with a modal property set. Data identifier modality is defined in the QUEST “Data Customization” section. If the specified data identifier is found, the data value will be returned, otherwise a value of $NULL is returned.

The $FCESEEK function must not be called in a startup macro since the block has yet to be broken down into its identifier components, nor is it useful to call this function in any shutdown macro since at that point all processing of identifiers has been completed.

The $FCESNCV Function

\textbf{{\char36}FCESNCV}\textbf{(}\icamhsp{0.707mm}\mathtt{\char39}\mathit{var}\,\mathtt{\char39},\mathit{val}\biggl[,\mathit{n_{1}}\Bigl[,\mathit{n_{2}}\,\bigl[,\mathit{n_{3}}\,\bigr]\,\Bigr]\,\biggr]\icamhsp{0.707mm}\textbf{)}

Set CNC variable in pre-processor

Returns: Logical

The pre-processor has logic to identify and process MCD that sets the value of CNC variables, so that it can later replace any use of a variable in the MCD with its actual value. The $FCESNCV function can be used if it is necessary to set the value of a CNC variable previously identified by the pre-processor. The variable must be specified in its native CNC format using the string var. If the variable represents a single, double or triple dimensioned table, then the table indices n1, n2 and n3 can be specified. Alternately, the variable definition var can include the proper CNC notation to de-reference the array or table cell instead of providing the indices as arguments. The value of the variable is specified with val which can be any data type supported by the CNC excluding a sequence.

A variable must be defined in the pre-processor before attempting to set it via the $FCESNCV function. The EXEC/'string' command can be used to define the CNC variable in whatever format the CNC expects.

The $FCESNCV function returns a status of $TRUE if the CNC variable was successfully set. A value of $FALSE is returned if the CNC variable could not be set or if a pre-processor is not in use.

The $FCETIMESYNC Function

\textbf{{\char36}FCETIMESYNC}\textbf{(}\icamhsp{0.707mm}\icamhsp{0.707mm}\textbf{)}

Enable merging lathe or composite CE channel synchronization

Returns: Logical

The $FCETIMESYNC function enables time synchronization across multiple CERUN kernels when running a merging lathe or composite CE configuration. Returns $TRUE if channel time synchronization is successfully enabled, or $FALSE with a diagnostic message if it is not.

When running CERUN in a merging lathe or composite CE configuration, multiple kernels process NC programs simultaneously. While Virtual Machine synchronizes the simulation of multiple channels in time, the NC programs themselves process as fast as possible without regard to timing. This function uses the Virtual Machine calculated cycle time on each channel to limit program processing so that all channels remain synchronized across the multiple CERUN kernels.

Requirements:

  • Merging lathe or composite CE configuration.

  • Virtual Machine must be active for simulation.

  • Must be called in the super CE “Machine Startup” macro.

The $FEOF Function

\textbf{{\char36}FEOF}\textbf{(}\icamhsp{0.707mm}\icamhsp{0.707mm}\textbf{)}

Test for end of MCD file

Returns: Logical

If the $FEOF function is called without arguments, it tests the end-of-file status of the input MCD file. It returns $TRUE if the MCD file has bee fully processed and $FALSE otherwise.

Note that the $FEOF function can be called with an argument to test for an end-of-file on any unit. See the $FEOF function in “File and Directory Functions”.

The $FGET and $FGETR Functions

\textbf{{\char36}FGET}\textbf{(}\icamhsp{0.707mm}\mathit{mcd}\Bigl[,\mathit{start}\,\bigl[,\mathit{end}\,\bigr]\,\Bigr]\icamhsp{0.707mm}\textbf{)}

Search forwards for a matching MCD block

Returns: Numeric

\textbf{{\char36}FGETR}\textbf{(}\icamhsp{0.707mm}\mathit{mcd}\Bigl[,\mathit{start}\,\bigl[,\mathit{end}\,\bigr]\,\Bigr]\icamhsp{0.707mm}\textbf{)}

Search backwards for a matching MCD block

Returns: Numeric

The $FGET function searches forward in the MCD file and the $FGETR function searches backward in the MCD file, looking for a record containing MCD matching the search string defined by the mcd string argument. The search string can contain special characters, in the form of a regular expression (RE). See the $FEDIT function for a description of RE’s.

Either a single search string or a sequence of search strings can be specified. The order of strings in the sequence is not important; the search ends at the first MCD block containing a match of any of the specified search strings.

The search starts at the current MCD block if the optional parameter start is not specified or is specified as 0 (zero). A $FGET searches forward in the MCD file, to the end of the MCD file or to the record designated by end if specified. A $FGETR searches backwards, to the start of the MCD file or to the record designated by end if specified. These functions return the MCD block index number of the first matching MCD block, and save a copy of the matching MCD block in the $MCDRD system variable. A value of 0 (zero) is returned if no matching MCD could be found.

Note that record numbers used and returned by these functions are not N block numbers; instead they are the block index number as counted from the start of the MCD file. The record number returned by these functions is compatible with the SEARCH command and the $MCDNO system variable.

The $FGET and $FGETR functions do not affect the current MCD input location.