Getting Started: Conditions

What Does This Article Cover?

  • What is a Condition?
  • Condition Considerations
  • Building a Deadband Condition
  • Building an Aggregate Condition
  • Custom Condition example
  • Other related material

What is a Condition?

Conditions provide an opportunity to alter the raw data read from an input. There are several types of conditions each with applicable settings including Aggregate, Alarm, Custom, and Deadband. Examples of Conditions capabilities include applying a Deadband to a raw input value so that data changes are only provided if the value has changed by a set threshold or applying JavaScript code to an array input to extract and rename the names of the elements in the array.

Condition Considerations:

Consider the following related to Conditions.

  • The Aggregate Condition calculates the numerical aggregates count, average, minimum, maximum, and delta over a sliding or fixed time period.
  • The Alarm Condition is used to monitor Connection Inputs and alarms when they stop providing data.
  • The Custom Condition is an opportunity to apply JavaScript code.
  • The Deadband Condition allows the configuration of an absolute value that the source must change to reflect the new value in the output. The source must change more than this absolute value.
  • When a Condition is used the Condition then becomes the source for the downstream data flow. For example, the Condition is referenced in an Instance instead of the Connection Input.
  • Sometimes the result of a Condition can be achieved in a Pipeline and a Pipeline may provide a more consolidated and visual solution.

Building a Deadband Condition

Perform the following steps to create a Deadband Condition.

  1. Navigate to Conditions and click the New Condition button in the upper right corner
  2. Within the Details screen, specify the following:

    Name (Required): Configuration Object name as it will be displayed in Intelligence Hub (Example Speed_Condition)

    Description (Optional): Brief description of the Configuration Object

    Tags (Optional): Used to group like Configuration Objects together
  3. Select the Condition type, in this case Deadband.
  4. On the Settings screen map the Input to the Sources using the drag and drop from the References

    Select the Reference Type

    Select the Reference Connection

    Select a specific Reference and drag into the Source field
  5. Enter a value for Absolute Deadband
  6. When finished click the Submit button

Building an Aggregate Condition

Perform the following steps to create an Aggregate Condition.

  1. Navigate to Conditions and click the New Condition button in the upper right corner
  2. Within the Details screen, specify the following:

    Name (Required): Configuration Object name as it will be displayed in the Intelligence Hub (Example Speed_Condition)

    Description (Optional): Brief description of the Configuration Object

    Tags (Optional): Used to group like Configuration Objects together
  3. Select the Condition type, in this case Aggregate.
  4. On the Settings screen, map the Input to the Sources using the drag and drop from the References

    Select the Reference Type

    Select the Reference Connection

    Select a specific Reference and drag into the Source field
  5. Enter values for Scan Interval, Storage Interval, Window Type, and Window Interval.
  6. Enable the Condition using the Enabled radio button
  7. When finished, click the Submit button

Custom Condition Example:

In this example, the goal is to obtain an array of identifiers to be used in a Dynamic Template for an Instance. A Custom Condition is used to obtain just the identifiers from a large and complex payload returned from a PI System assetmetadata Connection Input. The JavaScript code used in this custom condition is included below.

javascript
var metaData = {{this.currentValue}}
var outputArrayOut = []
var tagName = "ID"
var targetProperty = 'elementName'
for (item of metaData){
    if (targetProperty in item){
        var objectOut = {}
        objectOut[tagName] = item[targetProperty]
        outputArrayOut.push(objectOut)
    }
}
outputArrayOut

Other related material: