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

AVEVA™ Unified Engineering

Storage of Rules and Expressions

  • Last UpdatedOct 28, 2024
  • 2 minute read

Database Expressions

Database expressions are PML1 expressions, for example: (XLEN * 1000). Expressions are of the following type:

  • Double

  • DbElement

  • Bool

  • String

  • Position

  • Direction

  • Orientation

Database expressions are stored in various places in the AVEVA module as follows:

  • As part of a rule

  • Parameterization of the catalogue

There is a DbExpression class to hold an expression. An DbExpression may be obtained in one of the following ways:

  • Use the static method internalParse() that creates a DbExpression from a string, for example: internalParse("XLEN * 100")

  • Retrieve an expression from a rule

  • Retrieve an expression from a catalogue parameter

Having got an DbExpression there are two things that can be done with it:

  1. Turn it back into text

  2. Evaluate it against a given element

The methods to evaluate an expression against an element are on the DbElement class. There are different methods depending on the expected result of the expression. The method names start with 'Evaluate'. The method that returns a double has an argument for the units (distance/bore/none). The result will always be in millimetres (mm), for example:

DbExpression expr = DbExpression.Parse("DIAM OF PREV + 2");

double dval;

DbAttributeUnit units = DbAttributeUnit.DIST;

dval = nozz1.EvaluateDouble(expr4, units);

In this case the core system can work out that it is a distance, since DIAM is a distance. Thus although we specified that it was a distance, it was not strictly needed. Thus if the distance units were inch or finch then the '+2' would be interpreted as '+2inches'.

However consider:

DbExpression expr = DbExpression.Parse("10");

double dval;

DbAttributeUnit units = DbAttributeUnit.DIST;

dval = nozz1.EvaluateDouble(expr4, units);

In this case we do not know if "10" is 10mm or 10 inches. We must tell the system that it is a 'distance' unit. The system then interrogates the current distance units to return the result. If the current distance units is mm, then dval will be 10.0. If the current distance units is inch/finch then "10" is interpreted to mean 10 inches and is hence returned as 254.

Note:
If the value is required to be formatted for output, then it must be converted back in all cases. A method will be added to return values in local units at a later point.

Rules

PML.NET rules consist of an expression and a dynamic/static flag. When constructing a rule, the expression type is also needed.

There are methods on DbElement to:

  • Set a rule for any attribute.

  • Get a rule for any attribute

  • Evaluate a rule

  • Verify that the rule result is up to date

Pseudo Attributes Relating to Rules and Expressions

Attribute Name

Data Type

Qualifier

Description

NRULEE

Int

Number of rule inconsistencies on element

RCOU

Int

Number of rules on element

RULEER

String

int

Text of "nth" rule error

RULSET

DbAttribute[]

List of rules set

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