Chapter Formula Interpreter 1 - Introduction contained a brief description of the formula table. In this chapter we would like to describe it in more detail.
Each row in the table contains a formula. The table is especially suitable for simple and short formulas. Excel can be used to create and edit the table. The following figure shows a sheet with one formula:
Cell A1 must contain the string UniPlotFormulaTable or UniPlotFormelTabelle.
The second row contains the column headers.
The table can contain empty and comment rows. A comment row must start in column A with a # character. This can be used to disable formulas.
The table contains 8 columns:
The function name of the formula. It can be differently from the channel name. The name must begin with an alphabetic character, an underscore (‘_’), followed by zero or more alphanumeric characters including the underscore. Case is significant. The name should be unique. It should not appear again in the first column. It should not have also been used in any other IC file.
A brief formula description. It will be saved in the channel attribute Description in the NC file.
A string that specifies the units used for the channel’s data. The units will be saved in the channel attribute units in the NC file.
This column contains the name of the channel. The name is used to create a variable in the NC file. If the name already exists in the file, the channel data will be overwritten.
The name must begin with an alphabetic character or an underscore, followed by zero or more alphanumeric characters including the underscore (<tt>_</tt>) or numbers. Case is significant.
This column contains the formula definition.
In this column a condition can be indicated which will be used to decide whether the formula is to be applied to the active NC-file. If no condition is indicated (empty field), the frame work will try to evaluate the formula. How conditions are defined is described in the chapter Definition of a Condition. Examples of typical conditions:
diesel: Calculate this channel only with diesel engines.
otto: Calculate this channel only with petrol engines.
turbodiesel: Calculate this channel only with turbo charged diesel engines.
Format specification, e.g %e o %.4f. Further information about the format can be found in the documentation of printf. The format string is saved in channel attribute C_format in the NC file.
This column can contain a comment.
This table contains constants. Excel has been used to specifiy the constants, as shown in the following figure.
The constant names have to be unique. They should not be identical to any channel or attribute name used in your data files.
Before the function ch retrieves data for a given name it checks if a channel with this name already exists in the specified NC file. If a channel is not found the ch function tries to read the data from the global atributes in the NC file (header data). If this fails because a global attribute does not exist, the function checks for a constant with the given name in the constant table and returns its value.
The cell “A1” contains the string UniPlotFormulaConstants or UniPlotFormelKonstanten. The second row contains column titles.
The following rows contain constants. Each row contains 4 columns:
Constant name
Constant unit.
Brief description
Constant value.
The table can contain empty and comment rows. A comment row must start in column A with a # character. This can be used to disable formulas.
The constant table can be saved as a separate document or as a sheet in the formula document. The constant table will be converted as well during the formula conversion. To speed up access, the constant values will be saved in a UniPlot map.
To load specified formulas
If the table contains invalid formulas, a log file with error and warning messages is created. If all formulas are converted they can be applied to the data files.
Formulas are saved as UniScript functions. The file name is made up of the Excel file name plus sheet name and the extension .IC. Do not edit the file because it will be overwritten without notice the next time you convert the Excel formula file.
To debug a formula, open the appropriate IC file. To set a breakpoint, click on a row inside the function and press F9. If a breakpoint cannot be set, click F4 to translate the function and then press F9 again. A red dot will be displayed at the left border.
Open the data browser and press F9 to update the formulas. If the function can be calculated (all dependant channels are available in the file) the execution will stop at the breakpoint.
Use the F10 key to can step through instructions and the F11 key to enter into a function. To display a variable value, place the mouse cursor over a variable name.
For additional information, see The Debugger.
To next chapter Formula Interpreter 3 - Creating Script Formulas.
id-6196