auto_CalculateNCFormula¶
auto_CalculateNCFormula adds a calculated channel to an NC file.
- ssError = auto_CalculateNCFormula(ssNCFile, oFormula)
- ssError = auto_CalculateNCFormula(ncid, oFormula)
Return Value
ssError is an empty string (""
), if the formula could be calculated or a
string with an error message.
Parameters
- ssNCFile
ssNCFile
- ncid
ncid
- oFormula
oFormula is an object (see example) with the following elements
Element
Default Value
Description
ssFormula
required
Is the formla text. Example: (speed * torque) / 9549.3. See Defining Formulas.
ssOutputName
required
Is the formual channel name
ssUnit
""
Is the unit text.
ssDescription
""
Is a formula description.
ssOnlyIf
""
Name of a condition.
ssFormat
""
Number format: Format description, e.g. %g or %.2lf.
ssUseSIUnits
"0"
If set to the value “1”, the variables will be converted to SI units, before the formula is evaluated. The result will be converted to the specified unit in ssUnit.
rsDeleteICFile
TRUE (1)
If set to 0 the formula, created in the temp directory will not be deleted.
Comment
See Formula Interpreter 1 - Introduction for more information about how to define a formula. All channel names used in the formula must exist in the NC file. The formula may contain function calls. See Defining Formulas for a list of valid functions. The formula will not be registered. It will only be calculated ones.
Example
def test_auto_CalculateNCFormula()
{
ssNCFile = auto_ImportData(GetRootDirectory() + "samples/test1.xls");
oFormula = [.
ssFormula = "EngSpd * SAETrq / 9550",
ssOutputName = "Power",
ssUnit = "kW",
ssFormat="%.2lf"]; // 2 decimal places
ssError = auto_CalculateNCFormula(ssNCFile, oFormula)
if (ssError != "") {
log_error("", "auto_CalculateNCFormula", ssError);
error(ssError);
}
// NC_Edit(ssNCFile);
}
test_auto_CalculateNCFormula();
History
Version |
Description |
---|---|
R2014.3 |
New |
id-681772