Constructing a Python Expression
About this task
Procedure
- Open a text editor.
- 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.
- The raw data in your expression is exposed in the Python script as an object with the following properties:
- 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 thevalue
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 Pythonmath
module must be imported.