Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Production Management

About expressions

  • Last UpdatedNov 22, 2022
  • 3 minute read

An expression is a configurable property of an item such as a reporting point, capture condition, or calculated variable. It defines the customer-specific business logic.

TagA.Sample[Time].Value + TagB.Sample[Time].Value

An expression comprises:

  • A formula, which is a textual equation in a single line of C# code. The formula describes the calculation that AVEVA™ Production Management performs. The inputs into the formula can be any property of any item in your project. Generally, you use properties that are from the data sources such as SCADA, OPC, and OLE-DB.

  • Dependencies, which are the trigger conditions for the expressions in historized items. They define when AVEVA™ Production Management evaluates the formula, such as when a shift changes or the production run ends.

Calculations

An expression can perform calculations on data from various data sources. For example, expressions can determine when to create records for the AVEVA™ Production Management modules, and the values of the fields when AVEVA™ Production Management captures a record.

Typically, an expression compares or calculates the values or properties of items in the project. An expression can be as basic as the reading of a property value, or as complex as a calculation that involves immediate IF functions, concatenations, and data type conversions.

For complex calculations, the expression syntax must adhere to the rules.

Arithmetic overflows

When writing expression, be mindful of creating an arithmetic overflow situation. An arithmetic overflow occurs when a calculation produces a result that is greater than a given register or storage location can store or represent.

Examples:

integer * integer = integer

integer * double = double

double * integer = double

Triggers

AVEVA™ Production Management evaluates the expression whenever the trigger conditions are met. When you configure an item that contains an expression, you specify the expression and its dependencies. AVEVA™ Production Management evaluates the expression to produce the sample for the item, and the dependencies determine when the evaluation occurs.

When dependencies trigger the evaluation of the expression, AVEVA™ Production Management executes the expression to process data for a period when the necessary inputs are available for that period. AVEVA™ Production Management stores the result of the evaluation as a sample in a stream.

The name of an expression property varies depending on the item. For example, HistoricalFieldExpression is the name of the expression property for fields, and a virtual downtime capture condition has two expression properties: ActualExpression and TargetExpression.

Dependencies

The dependencies of an expression determine when AVEVA™ Production Management evaluates the expression of items that are historized. See, About historical data processing.

When you build expressions, you add dependencies that are item properties that sample streams define. When AVEVA™ Production Management detects new data, it checks for expressions that depend on the data. If the expressions have such dependencies, AVEVA™ Production Management evaluates the expression when relevant data is available for the time that AVEVA™ Production Management evaluates the expression.

Example

For example, the expression TagA.Sample[Time].Value + TagB.Sample[Time].Value depends on the Sample values of both TagA and TagB.

If any value is not available at the specific Time, AVEVA™ Production Management does not evaluate the expression. AVEVA™ Production Management monitors the values of TagA and TagB for the specified Time and evaluates the expression when both values are available. AVEVA™ Production Management executes the expression to process data for a period when the necessary inputs are available for that period.

Guidelines for building expressions

  • Configure the expression to result in a sample.

  • You can build one expression in each session of the Expression Editor, but you can add any number of dependencies to the expression.

  • You cannot write or paste an expression directly into the expression property in the Properties pane of Studio; use the Expression Editor to create the expression and add its dependencies.

  • You can use any valid C# mathematical or logical operator in the expression, for example, operators for multiplication, addition, subtraction, or division.

  • The result of the expression is of the data type selected for the item, such as the data type you select in the property of fields or the property of standard items. Set these properties before the item is started, and evaluated; otherwise, an incompatible data type may result in the value being lost.

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in