Constructing a Python Expression

About this task

Procedure

  1. Open a text editor.
  2. Construct an expression in Python that takes raw data and produces a calculated value you want to store in Historian.
    • The raw data in your expression is exposed in the Python script as an object with the following properties: value, is_quality_good, is_quality_bad, timestamp
    • You can give this object any name you want..
  3. Ensure that the expression you create is a valid Python expression (that is, it evaluates to a single value).
    For example, we call our object temp and we use the value property. We create a simple, valid Python expression, taking raw data (temp.value) and create a calculated value.
    temp.value + math.pow(10,temp.value/70)

    To use this example, temp.value must be defined and the Python math module must be imported.