Additional settings for calculations

When assigning a Variable with a Source set to Calc, a formula must be provided. A formula is an expression indicating how to compute the value of a variable based on other variables. For example, Overall Length = Length1 + Length2.

The calculation is performed only when the page reaches the calculation step for the first time. If the calculation has been performed at least once (that is the page has reached the calculation step for once), any subsequent changes to any value referenced in the calculated variable trigger the calculation to be performed again. This process prevents premature calculations and allows users to edit data that affects the results, ensuring accuracy.

Here are some examples of formulas; however, you can use any JavaScript Math function as required:

  • To: Express a conditional value
    • Use: (<test expression> ? <true value> : <false value>)
    • Example 1: ($$Oil Split$$ > 0 ? 1 : -1) Tests whether the value of the variable called Oil Split is greater than 0 and if this sets the target variable to 1, else set to -1
    • Example 2: ($$Var that could be zero$$ == 0 ? <desired value if 0> : $$Some other Var$$/$$Var that could be zero$$) Protect against potential division by zero
  • To: Take the Cosine of another variable
    • Use: Math.cos($$Variable$$)
    • Example: Math.cos($$Can Weight - Before$$)
  • To: Take the Sine of another variable
    • Use: Math.sin($$Variable$$)
    • Example: Math.sin($$Can Weight - Before$$)
  • To: Take the Logarithmic value of another variable
    • Use: Math.log($$Variable$$)
    • Example: Math.log($$Can Weight - Before$$)
  • To: Perform a Square root of another variable
    • Use: Math.sqrt($$Variable$$)
    • Example: Math.sqrt($$Can Weight - Before$$)
  • To: Take the maximum value of a collection of values derived from other variables
    • Use: Math.max($$Variable 1$$,$$Variable 2$$,$$Variable 3$$)
    • Example: Math.max($$Block Locator 1$$,$$Block Locator 2$$,$$Block Locator 3$$)
  • To: Take the minimum value of a collection of values derived from other variables
    • Use: Math.min($$Variable 1$$,$$Variable 2$$,$$Variable 3$$)
    • Example: Math.min($$Block Locator 1$$,$$Block Locator 2$$,$$Block Locator 3$$)
  • To: Obtain the power (square etc) of another variable
    • Use: Math.pow($$Variable$$,2)
    • Example: Math.pow($$Can Weight - Before$$,2)
  • To: Round another variable's value
    • Use: Math.round($$Variable$$)
    • Example: Math.round($$Can Weight - Before$$)

    The Infor MES functions calculate the average, maximum, minimum, range, or standard deviation value from another variable across all positions, all positions and samples, or all heads, samples, and positions. The syntax for referencing variables in these functions differs slightly from other formula variable references, as references the variable by name instead of using context placeholders. The reason is that context references insert a single value, while these functions require a variable name to operate on a set of values.

  • To: Calculate the Average, Maximum, Minimum, Range, or Standard Deviation of values across all heads, samples, and positions from another variable. This returns a single value, so ensure that the receiving variable is defined with a single head, sample, and position:
    • Use:
      • HAve('Variable Name')
      • HMax('Variable Name')
      • HMin('Variable Name')
      • HRng('Variable Name')
      • HStdDev('Variable Name')
    • Example:
      • HAve('Trim Height')
      • HRng('Trim Height')
      • HStdDev('Trim Height')
  • To: Calculate the average, maximum, minimum, range, or standard deviation of values across all samples and positions for each head of a different variable. This process yields a single value for each head, so the receiving variable should be defined with the same number of heads, however with only one sample and one position for each head:
    • Use:
      • SAve('Variable Name')
      • SMax('Variable Name')
      • SMin('Variable Name')
      • SRng('Variable Name')
      • SStdDev('Variable Name')
    • Example:
      • SAve('Trim Height')
      • SRng('Trim Height')
      • SStdDev('Trim Height')
  • To: Calculate the Average, Maximum, Minimum, Range, or Standard Deviation of values across all positions for each head and sample of another variable, use the following procedure. This returns a single value for each sample, so ensure that the receiving variable is defined with the same number of heads and samples, however only one position:
    • Use:
      • PAve('Variable Name')
      • PMax('Variable Name')
      • PMin('Variable Name')
      • PRng('Variable Name')
      • PStdDev('Variable Name')
    • Example:
      • PAve('Trim Height')
      • PRng('Trim Height')
      • PStdDev('Trim Height')
  • To: Reference a specific head, sample, position value from another variable
    • Use: $$Variable(HeadNo, SampleNo, PositionNo)$$
    • Example: $$Top Wall(1, 1, 1)$$
      Note: An * can be used for HSP such as $$Top Wall(*, *, 1)$$ that would use the current context passed in for that parameter.
  • To: Refer to the nominal or outer specification of this or another variable:
    • Use:
      • Nom('Variable Name')
      • Usl('Variable Name')
      • Lsl('Variable Name')
    • Example: Nom('Trim Height')
    Note: Variables that reference only their own specifications do not automatically update on the data entry page. This can only be refreshed when a different part of the formula is modified. To work around this, change the formula to include a changing variable, multiplying the value by 0 to avoid affecting the result, such as Nom("DENSITY") + $$FILLED_BOTTLE_WEIGHT$$ * 0.
  • Example:
    • A = FILLED_BOTTLE_WEIGHT -> Entered manually or comes from RS232 interface
    • B = DENSITY -> Formula to get the "nominal" value of the density of the liquid being filled. This density can be different for different part number and is maintained as specification, as in Nom("DENSITY") + $$FILLED_BOTTLE_WEIGHT$$ * 0
    • C = CLOSURE_WEIGHT -> Formula to get the nominal value of the weight of the “cap” being used. This weight can be different for different part number and is maintained as specification, as in Nom("CLOSURE_WEIGHT") + $$FILLED_BOTTLE_WEIGHT$$ * 0
    • D = WEIGHT (gm) -> Formula to get the nominal value of the weight of the “bottle” being used. This weight can be different for different part number and is maintained as specification, as in Nom("WEIGHT") + $$FILLED_BOTTLE_WEIGHT$$ * 0
    • E = NET_CONTENT (mls) = ((A – (C+D)) / B)